memorytalk 0.4.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.
- memorytalk-0.4.0/LICENSE +201 -0
- memorytalk-0.4.0/PKG-INFO +215 -0
- memorytalk-0.4.0/README.md +186 -0
- memorytalk-0.4.0/memorytalk/__init__.py +0 -0
- memorytalk-0.4.0/memorytalk/__main__.py +4 -0
- memorytalk-0.4.0/memorytalk/adapters/__init__.py +4 -0
- memorytalk-0.4.0/memorytalk/adapters/base.py +33 -0
- memorytalk-0.4.0/memorytalk/adapters/claude_code.py +119 -0
- memorytalk-0.4.0/memorytalk/api/__init__.py +100 -0
- memorytalk-0.4.0/memorytalk/api/cards.py +20 -0
- memorytalk-0.4.0/memorytalk/api/links.py +20 -0
- memorytalk-0.4.0/memorytalk/api/log.py +33 -0
- memorytalk-0.4.0/memorytalk/api/rebuild.py +21 -0
- memorytalk-0.4.0/memorytalk/api/search.py +18 -0
- memorytalk-0.4.0/memorytalk/api/sessions.py +18 -0
- memorytalk-0.4.0/memorytalk/api/status.py +25 -0
- memorytalk-0.4.0/memorytalk/api/tags.py +30 -0
- memorytalk-0.4.0/memorytalk/api/view.py +33 -0
- memorytalk-0.4.0/memorytalk/cli/__init__.py +21 -0
- memorytalk-0.4.0/memorytalk/cli/_format.py +435 -0
- memorytalk-0.4.0/memorytalk/cli/_http.py +73 -0
- memorytalk-0.4.0/memorytalk/cli/_render.py +71 -0
- memorytalk-0.4.0/memorytalk/cli/_setup_helpers.py +157 -0
- memorytalk-0.4.0/memorytalk/cli/card.py +41 -0
- memorytalk-0.4.0/memorytalk/cli/link.py +45 -0
- memorytalk-0.4.0/memorytalk/cli/log.py +32 -0
- memorytalk-0.4.0/memorytalk/cli/rebuild.py +31 -0
- memorytalk-0.4.0/memorytalk/cli/search.py +40 -0
- memorytalk-0.4.0/memorytalk/cli/server.py +146 -0
- memorytalk-0.4.0/memorytalk/cli/setup.py +429 -0
- memorytalk-0.4.0/memorytalk/cli/sync.py +57 -0
- memorytalk-0.4.0/memorytalk/cli/tag.py +51 -0
- memorytalk-0.4.0/memorytalk/cli/view.py +32 -0
- memorytalk-0.4.0/memorytalk/config.py +150 -0
- memorytalk-0.4.0/memorytalk/provider/__init__.py +0 -0
- memorytalk-0.4.0/memorytalk/provider/embedding.py +165 -0
- memorytalk-0.4.0/memorytalk/provider/lancedb.py +182 -0
- memorytalk-0.4.0/memorytalk/provider/storage.py +89 -0
- memorytalk-0.4.0/memorytalk/repository/__init__.py +18 -0
- memorytalk-0.4.0/memorytalk/repository/cards.py +124 -0
- memorytalk-0.4.0/memorytalk/repository/links.py +101 -0
- memorytalk-0.4.0/memorytalk/repository/schema.py +77 -0
- memorytalk-0.4.0/memorytalk/repository/search_log.py +105 -0
- memorytalk-0.4.0/memorytalk/repository/sessions.py +240 -0
- memorytalk-0.4.0/memorytalk/repository/store.py +50 -0
- memorytalk-0.4.0/memorytalk/schemas/__init__.py +51 -0
- memorytalk-0.4.0/memorytalk/schemas/cards.py +21 -0
- memorytalk-0.4.0/memorytalk/schemas/links.py +20 -0
- memorytalk-0.4.0/memorytalk/schemas/log.py +22 -0
- memorytalk-0.4.0/memorytalk/schemas/rebuild.py +12 -0
- memorytalk-0.4.0/memorytalk/schemas/search.py +44 -0
- memorytalk-0.4.0/memorytalk/schemas/sessions.py +37 -0
- memorytalk-0.4.0/memorytalk/schemas/shared.py +48 -0
- memorytalk-0.4.0/memorytalk/schemas/status.py +17 -0
- memorytalk-0.4.0/memorytalk/schemas/tags.py +14 -0
- memorytalk-0.4.0/memorytalk/schemas/view.py +36 -0
- memorytalk-0.4.0/memorytalk/service/__init__.py +25 -0
- memorytalk-0.4.0/memorytalk/service/cards.py +264 -0
- memorytalk-0.4.0/memorytalk/service/events.py +34 -0
- memorytalk-0.4.0/memorytalk/service/links.py +128 -0
- memorytalk-0.4.0/memorytalk/service/rebuild.py +130 -0
- memorytalk-0.4.0/memorytalk/service/search.py +182 -0
- memorytalk-0.4.0/memorytalk/service/sessions.py +309 -0
- memorytalk-0.4.0/memorytalk/util/__init__.py +0 -0
- memorytalk-0.4.0/memorytalk/util/dsl.py +327 -0
- memorytalk-0.4.0/memorytalk/util/ids.py +66 -0
- memorytalk-0.4.0/memorytalk/util/snippet.py +82 -0
- memorytalk-0.4.0/memorytalk/util/ttl.py +60 -0
- memorytalk-0.4.0/memorytalk.egg-info/PKG-INFO +215 -0
- memorytalk-0.4.0/memorytalk.egg-info/SOURCES.txt +74 -0
- memorytalk-0.4.0/memorytalk.egg-info/dependency_links.txt +1 -0
- memorytalk-0.4.0/memorytalk.egg-info/entry_points.txt +2 -0
- memorytalk-0.4.0/memorytalk.egg-info/requires.txt +21 -0
- memorytalk-0.4.0/memorytalk.egg-info/top_level.txt +1 -0
- memorytalk-0.4.0/pyproject.toml +57 -0
- memorytalk-0.4.0/setup.cfg +4 -0
memorytalk-0.4.0/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 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 [yyyy] [name of copyright owner]
|
|
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,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: memorytalk
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Persistent cross-session memory for AI agents via Talk-Card architecture (v2)
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: click>=8.1.0
|
|
10
|
+
Requires-Dist: pydantic>=2.0.0
|
|
11
|
+
Requires-Dist: fastapi>=0.109.0
|
|
12
|
+
Requires-Dist: uvicorn>=0.27.0
|
|
13
|
+
Requires-Dist: httpx>=0.25.0
|
|
14
|
+
Requires-Dist: lancedb>=0.6.0
|
|
15
|
+
Requires-Dist: numpy>=1.24.0
|
|
16
|
+
Requires-Dist: python-ulid>=2.0.0
|
|
17
|
+
Requires-Dist: jieba>=0.42.1
|
|
18
|
+
Requires-Dist: pyarrow>=14.0.0
|
|
19
|
+
Requires-Dist: aiosqlite>=0.19.0
|
|
20
|
+
Requires-Dist: aiofiles>=23.0.0
|
|
21
|
+
Requires-Dist: rich>=13.0.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
26
|
+
Provides-Extra: local
|
|
27
|
+
Requires-Dist: sentence-transformers>=2.2.0; extra == "local"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# memory.talk
|
|
31
|
+
|
|
32
|
+
> 给 AI agent 跨会话的持久记忆
|
|
33
|
+
|
|
34
|
+
memory.talk 把你跟 Claude Code、Codex 等 AI 平台的对话历史压缩成**可搜索的认知卡片**(Talk-Card),让下一次会话能"想起"之前的决定、踩过的坑、架构选型。本地存储,零配置启动,可插拔到 Qdrant / PostgreSQL 等后端。
|
|
35
|
+
|
|
36
|
+
[English](README-EN.md) · [CLI 文档](docs/cli/v2/README.md)
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 它解决什么问题
|
|
41
|
+
|
|
42
|
+
你每次开新会话都要给 AI 复述项目背景、再次走过同样的弯路 —— 因为每次会话都是空白。memory.talk 让这个过程变成:
|
|
43
|
+
|
|
44
|
+
1. **导入**过去的会话(`memory-talk sync`)
|
|
45
|
+
2. **提炼**对话成 cards(LLM 通过 `card` 命令落地)
|
|
46
|
+
3. AI 启动时 hook **自动召回**相关记忆(`recall`)
|
|
47
|
+
4. AI 思考过程中**主动检索**(`search`)
|
|
48
|
+
|
|
49
|
+
不是又一个 RAG 库 —— memory.talk 把 retrieval 拆成"无意识召回"和"有意识检索"两种正交的语义。
|
|
50
|
+
|
|
51
|
+
## 快速开始
|
|
52
|
+
|
|
53
|
+
### 安装
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install memorytalk
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
或从源码:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/memory-co/memory.talk.git
|
|
63
|
+
cd memory.talk
|
|
64
|
+
pip install -e .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 初始化
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
memory-talk setup
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
交互式 wizard 会问你 embedding provider(`local` / `openai`)、port、向量库、关系库等,自动写 `~/.memory-talk/settings.json`,可选立刻启动后台服务,顺便建一个 `memory.talk` 软链(等价于 `memory-talk`)。
|
|
74
|
+
|
|
75
|
+
> setup 可重复跑 —— 第二次会进"修改模式",每个字段默认就是当前值,Enter 跳过,改了就询问是否重启服务。
|
|
76
|
+
|
|
77
|
+
### 跑起来
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 从 Claude Code / Codex 平台导入历史会话
|
|
81
|
+
memory-talk sync
|
|
82
|
+
|
|
83
|
+
# 搜索一下
|
|
84
|
+
memory-talk search "LanceDB 选型"
|
|
85
|
+
|
|
86
|
+
# 读一条 card 详情
|
|
87
|
+
memory-talk view card_01jz8k2m
|
|
88
|
+
|
|
89
|
+
# 看一条 session 的生命周期事件
|
|
90
|
+
memory-talk log sess_xxx
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
完整命令列表 → [docs/cli/v2/](docs/cli/v2/README.md)
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 核心概念
|
|
98
|
+
|
|
99
|
+
### Talk-Card
|
|
100
|
+
|
|
101
|
+
一张压缩的认知单元(≤1024 tokens),由 LLM 从 session 的特定 round 中提炼:
|
|
102
|
+
|
|
103
|
+
- **Summary** —— 一句话,作为 embedding 锚点
|
|
104
|
+
- **Rounds** —— 关键决策 / 推理片段
|
|
105
|
+
- **Links** —— 跟其它 cards / sessions 的语义关联
|
|
106
|
+
- **Default Link** —— 每张 card 自动跟它的来源 session 关联,生死跟随 card
|
|
107
|
+
|
|
108
|
+
> cards 是"已经想过的东西",sessions 是"原始对话"。
|
|
109
|
+
|
|
110
|
+
### Search vs Recall
|
|
111
|
+
|
|
112
|
+
| | `search` | `recall` |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| 触发 | AI 思考时主动调用 | harness hook 自动调用 |
|
|
115
|
+
| 意识形态 | 有意识 / 决定要查 | 无意识 / 看到 prompt 即浮现 |
|
|
116
|
+
| 输出 | 完整结构(snippets / links / tags) | 极简(`memory-talk view <id> # summary`) |
|
|
117
|
+
| 去重 | 无 | 同 session 已召回过的不再返回 |
|
|
118
|
+
|
|
119
|
+
底层都建在 **hybrid FTS + 向量** 之上(LanceDB)。
|
|
120
|
+
|
|
121
|
+
### 存储布局
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
~/.memory-talk/
|
|
125
|
+
├── settings.json
|
|
126
|
+
├── sessions/<source>/<bucket>/<sess_id>/
|
|
127
|
+
│ ├── meta.json
|
|
128
|
+
│ ├── rounds.jsonl # 对话流(append-only)
|
|
129
|
+
│ └── events.jsonl # 生命周期事件
|
|
130
|
+
├── cards/<bucket>/<card_id>/
|
|
131
|
+
│ ├── card.json
|
|
132
|
+
│ └── events.jsonl
|
|
133
|
+
├── links/<bucket>/<link_id>.json
|
|
134
|
+
├── vectors/ # LanceDB
|
|
135
|
+
├── memory.db # SQLite(派生索引)
|
|
136
|
+
└── logs/search/<UTC-day>.jsonl
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**文件层是 source of truth**,SQLite + LanceDB 都是从文件可重建的派生索引。`memory-talk rebuild` 随时可以从文件重建出全部索引。
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 输出格式
|
|
144
|
+
|
|
145
|
+
CLI 默认输出 **Markdown**,运行时按 stdout 是否 TTY 自动决定渲染:
|
|
146
|
+
|
|
147
|
+
- TTY 终端 → 用 `rich` 渲染成带样式的输出
|
|
148
|
+
- 管道 / 脚本 / LLM 消费 → 原始 Markdown(LLM 训练里 Markdown 本就是常见格式)
|
|
149
|
+
- `--json` → 结构化 JSON,机器友好
|
|
150
|
+
|
|
151
|
+
错误也跟着走:Markdown 模式 `**error:** <msg>` 写到 stderr,JSON 模式写到 stdout。
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 设计原则
|
|
156
|
+
|
|
157
|
+
- **Python 不调 LLM**:数据层只做 CRUD / embedding / 向量检索,不做认知。LLM 通过 CLI 调用,认知发生在外部。
|
|
158
|
+
- **可插拔的 storage 抽象**:`provider/storage.py` 定义统一原语(write/read/append/list/delete),local-fs 是当前实现,后续可加 S3。Domain ops(write_session_meta 等)在 `repository/<domain>.py` 里调原语,不直接 open 文件。
|
|
159
|
+
- **rebuild 永远可行**:任何时候删掉 `memory.db` + `vectors/` 跑 `memory-talk rebuild`,从文件层完整还原。
|
|
160
|
+
- **rebuild 期间 server 进入维护模式**:除了 `/v2/status`,所有 API 503 拦掉,避免读到撕裂的中间态。
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 命令一览
|
|
165
|
+
|
|
166
|
+
| 命令 | 用途 |
|
|
167
|
+
|---|---|
|
|
168
|
+
| [`setup`](docs/cli/v2/setup.md) | 交互式安装 / 改配置 / 重启 |
|
|
169
|
+
| [`sync`](docs/cli/v2/sync.md) | 从 Claude Code 等平台导入 session |
|
|
170
|
+
| [`search`](docs/cli/v2/search.md) | 有意识检索(混合 FTS + 向量) |
|
|
171
|
+
| [`recall`](docs/cli/v2/recall.md) | hook 自动召回(极简形式) |
|
|
172
|
+
| [`view`](docs/cli/v2/view.md) | 读单条 card / session |
|
|
173
|
+
| [`log`](docs/cli/v2/log.md) | 看对象生命周期事件流 |
|
|
174
|
+
| [`card`](docs/cli/v2/card.md) | 创建 card |
|
|
175
|
+
| [`tag`](docs/cli/v2/tag.md) | 给 session 打 tag |
|
|
176
|
+
| [`link`](docs/cli/v2/link.md) | 写用户 link |
|
|
177
|
+
| [`server`](docs/cli/v2/server.md) | 管理本地 API 服务 |
|
|
178
|
+
| [`rebuild`](docs/cli/v2/rebuild.md) | 从文件层重建索引 |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 开发
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
pip install -e ".[dev]"
|
|
186
|
+
pytest memorytalk/tests/
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
跑搜索质量回归(用真 DashScope embedding):
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
export QWEN_KEY=sk-...
|
|
193
|
+
pytest memorytalk/tests/search/
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
测试套结构:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
memorytalk/tests/
|
|
200
|
+
├── api/ # FastAPI TestClient
|
|
201
|
+
├── cli/ # 真 CLI(ASGI 路由 + subprocess)
|
|
202
|
+
├── service/ # 服务层(真 SQLite + LanceDB + dummy embedder)
|
|
203
|
+
├── provider/ # storage / embedding 原语
|
|
204
|
+
├── config/ # Config 加载 + 校验
|
|
205
|
+
├── util/ # dsl / ids / snippet / ttl
|
|
206
|
+
└── search/ # 搜索质量回归(5 档评分:Excellent/Acceptable/Marginal/Degraded/Failed)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
184+ 个测试,场景化目录(每个测试用例一个目录,带自己的 README + test.py)。详见 [tests/](memorytalk/tests/)。
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
[Apache License 2.0](LICENSE)
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# memory.talk
|
|
2
|
+
|
|
3
|
+
> 给 AI agent 跨会话的持久记忆
|
|
4
|
+
|
|
5
|
+
memory.talk 把你跟 Claude Code、Codex 等 AI 平台的对话历史压缩成**可搜索的认知卡片**(Talk-Card),让下一次会话能"想起"之前的决定、踩过的坑、架构选型。本地存储,零配置启动,可插拔到 Qdrant / PostgreSQL 等后端。
|
|
6
|
+
|
|
7
|
+
[English](README-EN.md) · [CLI 文档](docs/cli/v2/README.md)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 它解决什么问题
|
|
12
|
+
|
|
13
|
+
你每次开新会话都要给 AI 复述项目背景、再次走过同样的弯路 —— 因为每次会话都是空白。memory.talk 让这个过程变成:
|
|
14
|
+
|
|
15
|
+
1. **导入**过去的会话(`memory-talk sync`)
|
|
16
|
+
2. **提炼**对话成 cards(LLM 通过 `card` 命令落地)
|
|
17
|
+
3. AI 启动时 hook **自动召回**相关记忆(`recall`)
|
|
18
|
+
4. AI 思考过程中**主动检索**(`search`)
|
|
19
|
+
|
|
20
|
+
不是又一个 RAG 库 —— memory.talk 把 retrieval 拆成"无意识召回"和"有意识检索"两种正交的语义。
|
|
21
|
+
|
|
22
|
+
## 快速开始
|
|
23
|
+
|
|
24
|
+
### 安装
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install memorytalk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
或从源码:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/memory-co/memory.talk.git
|
|
34
|
+
cd memory.talk
|
|
35
|
+
pip install -e .
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 初始化
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
memory-talk setup
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
交互式 wizard 会问你 embedding provider(`local` / `openai`)、port、向量库、关系库等,自动写 `~/.memory-talk/settings.json`,可选立刻启动后台服务,顺便建一个 `memory.talk` 软链(等价于 `memory-talk`)。
|
|
45
|
+
|
|
46
|
+
> setup 可重复跑 —— 第二次会进"修改模式",每个字段默认就是当前值,Enter 跳过,改了就询问是否重启服务。
|
|
47
|
+
|
|
48
|
+
### 跑起来
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# 从 Claude Code / Codex 平台导入历史会话
|
|
52
|
+
memory-talk sync
|
|
53
|
+
|
|
54
|
+
# 搜索一下
|
|
55
|
+
memory-talk search "LanceDB 选型"
|
|
56
|
+
|
|
57
|
+
# 读一条 card 详情
|
|
58
|
+
memory-talk view card_01jz8k2m
|
|
59
|
+
|
|
60
|
+
# 看一条 session 的生命周期事件
|
|
61
|
+
memory-talk log sess_xxx
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
完整命令列表 → [docs/cli/v2/](docs/cli/v2/README.md)
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 核心概念
|
|
69
|
+
|
|
70
|
+
### Talk-Card
|
|
71
|
+
|
|
72
|
+
一张压缩的认知单元(≤1024 tokens),由 LLM 从 session 的特定 round 中提炼:
|
|
73
|
+
|
|
74
|
+
- **Summary** —— 一句话,作为 embedding 锚点
|
|
75
|
+
- **Rounds** —— 关键决策 / 推理片段
|
|
76
|
+
- **Links** —— 跟其它 cards / sessions 的语义关联
|
|
77
|
+
- **Default Link** —— 每张 card 自动跟它的来源 session 关联,生死跟随 card
|
|
78
|
+
|
|
79
|
+
> cards 是"已经想过的东西",sessions 是"原始对话"。
|
|
80
|
+
|
|
81
|
+
### Search vs Recall
|
|
82
|
+
|
|
83
|
+
| | `search` | `recall` |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| 触发 | AI 思考时主动调用 | harness hook 自动调用 |
|
|
86
|
+
| 意识形态 | 有意识 / 决定要查 | 无意识 / 看到 prompt 即浮现 |
|
|
87
|
+
| 输出 | 完整结构(snippets / links / tags) | 极简(`memory-talk view <id> # summary`) |
|
|
88
|
+
| 去重 | 无 | 同 session 已召回过的不再返回 |
|
|
89
|
+
|
|
90
|
+
底层都建在 **hybrid FTS + 向量** 之上(LanceDB)。
|
|
91
|
+
|
|
92
|
+
### 存储布局
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
~/.memory-talk/
|
|
96
|
+
├── settings.json
|
|
97
|
+
├── sessions/<source>/<bucket>/<sess_id>/
|
|
98
|
+
│ ├── meta.json
|
|
99
|
+
│ ├── rounds.jsonl # 对话流(append-only)
|
|
100
|
+
│ └── events.jsonl # 生命周期事件
|
|
101
|
+
├── cards/<bucket>/<card_id>/
|
|
102
|
+
│ ├── card.json
|
|
103
|
+
│ └── events.jsonl
|
|
104
|
+
├── links/<bucket>/<link_id>.json
|
|
105
|
+
├── vectors/ # LanceDB
|
|
106
|
+
├── memory.db # SQLite(派生索引)
|
|
107
|
+
└── logs/search/<UTC-day>.jsonl
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**文件层是 source of truth**,SQLite + LanceDB 都是从文件可重建的派生索引。`memory-talk rebuild` 随时可以从文件重建出全部索引。
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 输出格式
|
|
115
|
+
|
|
116
|
+
CLI 默认输出 **Markdown**,运行时按 stdout 是否 TTY 自动决定渲染:
|
|
117
|
+
|
|
118
|
+
- TTY 终端 → 用 `rich` 渲染成带样式的输出
|
|
119
|
+
- 管道 / 脚本 / LLM 消费 → 原始 Markdown(LLM 训练里 Markdown 本就是常见格式)
|
|
120
|
+
- `--json` → 结构化 JSON,机器友好
|
|
121
|
+
|
|
122
|
+
错误也跟着走:Markdown 模式 `**error:** <msg>` 写到 stderr,JSON 模式写到 stdout。
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 设计原则
|
|
127
|
+
|
|
128
|
+
- **Python 不调 LLM**:数据层只做 CRUD / embedding / 向量检索,不做认知。LLM 通过 CLI 调用,认知发生在外部。
|
|
129
|
+
- **可插拔的 storage 抽象**:`provider/storage.py` 定义统一原语(write/read/append/list/delete),local-fs 是当前实现,后续可加 S3。Domain ops(write_session_meta 等)在 `repository/<domain>.py` 里调原语,不直接 open 文件。
|
|
130
|
+
- **rebuild 永远可行**:任何时候删掉 `memory.db` + `vectors/` 跑 `memory-talk rebuild`,从文件层完整还原。
|
|
131
|
+
- **rebuild 期间 server 进入维护模式**:除了 `/v2/status`,所有 API 503 拦掉,避免读到撕裂的中间态。
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 命令一览
|
|
136
|
+
|
|
137
|
+
| 命令 | 用途 |
|
|
138
|
+
|---|---|
|
|
139
|
+
| [`setup`](docs/cli/v2/setup.md) | 交互式安装 / 改配置 / 重启 |
|
|
140
|
+
| [`sync`](docs/cli/v2/sync.md) | 从 Claude Code 等平台导入 session |
|
|
141
|
+
| [`search`](docs/cli/v2/search.md) | 有意识检索(混合 FTS + 向量) |
|
|
142
|
+
| [`recall`](docs/cli/v2/recall.md) | hook 自动召回(极简形式) |
|
|
143
|
+
| [`view`](docs/cli/v2/view.md) | 读单条 card / session |
|
|
144
|
+
| [`log`](docs/cli/v2/log.md) | 看对象生命周期事件流 |
|
|
145
|
+
| [`card`](docs/cli/v2/card.md) | 创建 card |
|
|
146
|
+
| [`tag`](docs/cli/v2/tag.md) | 给 session 打 tag |
|
|
147
|
+
| [`link`](docs/cli/v2/link.md) | 写用户 link |
|
|
148
|
+
| [`server`](docs/cli/v2/server.md) | 管理本地 API 服务 |
|
|
149
|
+
| [`rebuild`](docs/cli/v2/rebuild.md) | 从文件层重建索引 |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 开发
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
pip install -e ".[dev]"
|
|
157
|
+
pytest memorytalk/tests/
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
跑搜索质量回归(用真 DashScope embedding):
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
export QWEN_KEY=sk-...
|
|
164
|
+
pytest memorytalk/tests/search/
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
测试套结构:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
memorytalk/tests/
|
|
171
|
+
├── api/ # FastAPI TestClient
|
|
172
|
+
├── cli/ # 真 CLI(ASGI 路由 + subprocess)
|
|
173
|
+
├── service/ # 服务层(真 SQLite + LanceDB + dummy embedder)
|
|
174
|
+
├── provider/ # storage / embedding 原语
|
|
175
|
+
├── config/ # Config 加载 + 校验
|
|
176
|
+
├── util/ # dsl / ids / snippet / ttl
|
|
177
|
+
└── search/ # 搜索质量回归(5 档评分:Excellent/Acceptable/Marginal/Degraded/Failed)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
184+ 个测试,场景化目录(每个测试用例一个目录,带自己的 README + test.py)。详见 [tests/](memorytalk/tests/)。
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
[Apache License 2.0](LICENSE)
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Base adapter interface for CLI `sync`."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Iterator
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BaseAdapter(ABC):
|
|
9
|
+
"""Adapter for a source platform (claude-code / codex / ...).
|
|
10
|
+
|
|
11
|
+
`iter_sessions(root)` yields ingest payloads — dicts with the shape of
|
|
12
|
+
POST /v2/sessions body, including a computed sha256 for content hashing.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
source_name: str
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def iter_sessions(self, root: Path | None = None) -> Iterator[dict]: ...
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
ADAPTERS: dict[str, type[BaseAdapter]] = {}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def register(cls: type[BaseAdapter]) -> type[BaseAdapter]:
|
|
25
|
+
ADAPTERS[cls.source_name] = cls
|
|
26
|
+
return cls
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_adapter(name: str) -> BaseAdapter:
|
|
30
|
+
cls = ADAPTERS.get(name)
|
|
31
|
+
if not cls:
|
|
32
|
+
raise ValueError(f"unknown adapter: {name}")
|
|
33
|
+
return cls()
|