dsh-shiori 0.0.0-stage → 0.2.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 +170 -0
- package/README.md +248 -2
- package/client/index.js +4202 -0
- package/client/shiori.css +127 -0
- package/cordis.patch.yml +8 -0
- package/docs/plugin/INSTALL.md +68 -0
- package/docs/plugin/client.md +93 -0
- package/icon.png +0 -0
- package/index.mjs +76 -0
- package/package.json +92 -6
- package/src/acceptance/cli.mjs +116 -0
- package/src/acceptance/global-fallback-child.mjs +79 -0
- package/src/acceptance/index.mjs +1477 -0
- package/src/acceptance/loopback-capture.mjs +316 -0
- package/src/acceptance/restart-child.mjs +106 -0
- package/src/acceptance/synthetic.mjs +363 -0
- package/src/completion/errors.mjs +48 -0
- package/src/completion/index.mjs +424 -0
- package/src/core/budget.mjs +99 -0
- package/src/core/config.mjs +130 -0
- package/src/core/errors.mjs +68 -0
- package/src/core/index.mjs +18 -0
- package/src/core/keys.mjs +70 -0
- package/src/core/render.mjs +69 -0
- package/src/core/topics.mjs +136 -0
- package/src/forgetting/cold-search.mjs +284 -0
- package/src/forgetting/decay.mjs +677 -0
- package/src/forgetting/executor.mjs +347 -0
- package/src/host/compress-probe.mjs +518 -0
- package/src/host/dsh-adapter.mjs +379 -0
- package/src/host/errors.mjs +44 -0
- package/src/host/index.mjs +535 -0
- package/src/host/readonly-guard.mjs +242 -0
- package/src/host/seat.mjs +451 -0
- package/src/host/tools.mjs +582 -0
- package/src/organize/analyze.mjs +541 -0
- package/src/organize/executor.mjs +680 -0
- package/src/organize/queue.mjs +1350 -0
- package/src/plugin/bindings.mjs +283 -0
- package/src/plugin/client-rpc.mjs +317 -0
- package/src/plugin/config.mjs +655 -0
- package/src/plugin/controller.mjs +1653 -0
- package/src/plugin/management.mjs +826 -0
- package/src/plugin/persona.mjs +348 -0
- package/src/plugin/protocol.mjs +680 -0
- package/src/plugin/scope.mjs +371 -0
- package/src/plugin/state.mjs +666 -0
- package/src/plugin/tool-schemas.mjs +250 -0
- package/src/plugin/typert-descriptors.mjs +236 -0
- package/src/runtime/index.mjs +656 -0
- package/src/semantic/index.mjs +185 -0
- package/src/semantic/local.mjs +161 -0
- package/src/semantic/store.mjs +239 -0
- package/src/service/index.mjs +231 -0
- package/src/sparks/delivery.mjs +214 -0
- package/src/sparks/errors.mjs +63 -0
- package/src/sparks/graph.mjs +278 -0
- package/src/sparks/match.mjs +332 -0
- package/src/sparks/semantic-recall.mjs +228 -0
- package/src/sparks/store.mjs +1930 -0
- package/src/sparks/tools.mjs +477 -0
- package/src/storage/errors.mjs +46 -0
- package/src/storage/frontmatter.mjs +186 -0
- package/src/storage/fsutil.mjs +134 -0
- package/src/storage/index.mjs +5 -0
- package/src/storage/journal.mjs +127 -0
- package/src/storage/lockfile.mjs +269 -0
- package/src/storage/paths.mjs +216 -0
- package/src/storage/store.mjs +1079 -0
- package/src/timeline/index.mjs +345 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
|
|
2
|
+
|
|
3
|
+
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
|
4
|
+
|
|
5
|
+
Using Creative Commons Public Licenses
|
|
6
|
+
|
|
7
|
+
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
|
8
|
+
|
|
9
|
+
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
|
|
10
|
+
|
|
11
|
+
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
|
|
12
|
+
|
|
13
|
+
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
|
|
14
|
+
|
|
15
|
+
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
|
16
|
+
|
|
17
|
+
Section 1 – Definitions.
|
|
18
|
+
|
|
19
|
+
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
|
20
|
+
|
|
21
|
+
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
|
22
|
+
|
|
23
|
+
c. BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
|
|
24
|
+
|
|
25
|
+
d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
|
26
|
+
|
|
27
|
+
e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
|
28
|
+
|
|
29
|
+
f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
|
30
|
+
|
|
31
|
+
g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
|
|
32
|
+
|
|
33
|
+
h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
|
34
|
+
|
|
35
|
+
i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
|
36
|
+
|
|
37
|
+
j. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
|
|
38
|
+
|
|
39
|
+
k. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
|
40
|
+
|
|
41
|
+
l. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
|
42
|
+
|
|
43
|
+
m. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
|
44
|
+
|
|
45
|
+
n. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
|
46
|
+
|
|
47
|
+
Section 2 – Scope.
|
|
48
|
+
|
|
49
|
+
a. License grant.
|
|
50
|
+
|
|
51
|
+
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
|
52
|
+
|
|
53
|
+
A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
|
|
54
|
+
|
|
55
|
+
B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
|
|
56
|
+
|
|
57
|
+
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
|
58
|
+
|
|
59
|
+
3. Term. The term of this Public License is specified in Section 6(a).
|
|
60
|
+
|
|
61
|
+
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
|
62
|
+
|
|
63
|
+
5. Downstream recipients.
|
|
64
|
+
|
|
65
|
+
A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
|
66
|
+
|
|
67
|
+
B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
|
|
68
|
+
|
|
69
|
+
C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
|
70
|
+
|
|
71
|
+
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
|
72
|
+
|
|
73
|
+
b. Other rights.
|
|
74
|
+
|
|
75
|
+
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
|
76
|
+
|
|
77
|
+
2. Patent and trademark rights are not licensed under this Public License.
|
|
78
|
+
|
|
79
|
+
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
|
|
80
|
+
|
|
81
|
+
Section 3 – License Conditions.
|
|
82
|
+
|
|
83
|
+
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
|
84
|
+
|
|
85
|
+
a. Attribution.
|
|
86
|
+
|
|
87
|
+
1. If You Share the Licensed Material (including in modified form), You must:
|
|
88
|
+
|
|
89
|
+
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
|
90
|
+
|
|
91
|
+
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
|
92
|
+
|
|
93
|
+
ii. a copyright notice;
|
|
94
|
+
|
|
95
|
+
iii. a notice that refers to this Public License;
|
|
96
|
+
|
|
97
|
+
iv. a notice that refers to the disclaimer of warranties;
|
|
98
|
+
|
|
99
|
+
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
|
100
|
+
|
|
101
|
+
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
|
102
|
+
|
|
103
|
+
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
|
104
|
+
|
|
105
|
+
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
|
106
|
+
|
|
107
|
+
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
|
108
|
+
|
|
109
|
+
b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
|
|
110
|
+
|
|
111
|
+
1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
|
|
112
|
+
|
|
113
|
+
2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
|
|
114
|
+
|
|
115
|
+
3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
|
|
116
|
+
|
|
117
|
+
Section 4 – Sui Generis Database Rights.
|
|
118
|
+
|
|
119
|
+
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
|
120
|
+
|
|
121
|
+
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
|
|
122
|
+
|
|
123
|
+
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
|
|
124
|
+
|
|
125
|
+
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
|
126
|
+
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
|
127
|
+
|
|
128
|
+
Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
|
129
|
+
|
|
130
|
+
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
|
131
|
+
|
|
132
|
+
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
|
133
|
+
|
|
134
|
+
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
|
135
|
+
|
|
136
|
+
Section 6 – Term and Termination.
|
|
137
|
+
|
|
138
|
+
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
|
139
|
+
|
|
140
|
+
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
|
141
|
+
|
|
142
|
+
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
|
143
|
+
|
|
144
|
+
2. upon express reinstatement by the Licensor.
|
|
145
|
+
|
|
146
|
+
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
|
147
|
+
|
|
148
|
+
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
|
149
|
+
|
|
150
|
+
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
|
151
|
+
|
|
152
|
+
Section 7 – Other Terms and Conditions.
|
|
153
|
+
|
|
154
|
+
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
|
155
|
+
|
|
156
|
+
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
|
157
|
+
|
|
158
|
+
Section 8 – Interpretation.
|
|
159
|
+
|
|
160
|
+
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
|
161
|
+
|
|
162
|
+
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
|
163
|
+
|
|
164
|
+
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
|
165
|
+
|
|
166
|
+
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
|
167
|
+
|
|
168
|
+
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
|
169
|
+
|
|
170
|
+
Creative Commons may be contacted at creativecommons.org.
|
package/README.md
CHANGED
|
@@ -1,3 +1,249 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-shiori
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 给 DeepSeek Harness 的 agent 一套**分层、会长、也会忘**的长期记忆:人设卡常驻开头,记忆核心每轮注入,原子卡片在你说到它时自己浮上来,长文档式专题按需展开——满了自己下沉,旧了自己淡出。
|
|
4
|
+
|
|
5
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
6
|
+
[](https://www.npmjs.com/package/dsh-shiori)
|
|
7
|
+
[](https://www.npmjs.com/package/dsh-shiori)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 一分钟了解
|
|
13
|
+
|
|
14
|
+
聊天记录会越滚越长,但模型的上下文不会。你要么把一切都塞进去(然后被截断、被压缩、花光 token),要么就接受它每次醒来都失忆。dsh-shiori 是第三种选择:**把记忆从对话里搬出来,分层存放,按需要取用**。
|
|
15
|
+
|
|
16
|
+
| 层 | 存什么 | 什么时候进上下文 |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| **L0** 人设卡 | 身份、性格、说话方式 | 每轮常驻,摆在对话最前面 |
|
|
19
|
+
| **L1** 记忆核心 | 最重要的事实、约定、进行中的事,外加一份专题目录 | 每轮常驻;超预算先压到软目标,硬上限之前绝不截断 |
|
|
20
|
+
| **L2** Spark 卡片 | 一条一条的原子记忆:某个梗、某个外号、某个小事实 | 默认不进;你说到相关的话,按触发词自己浮上来 |
|
|
21
|
+
| **L3** 专题 | 长文式的沉淀:一个项目的来龙去脉、一份研究笔记 | 只露一行索引;模型觉得需要才去读全文 |
|
|
22
|
+
|
|
23
|
+
它想解决的三件事:
|
|
24
|
+
|
|
25
|
+
| 你担心的 | 插件怎么处理 |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| 记忆越写越多,最后把上下文撑爆 | 每层各有预算;L1 装满后把细节**下沉**到 L3 专题,只留索引占一行;索引再挤就归档 |
|
|
28
|
+
| 存进去就再也想不起来 | L2 卡带触发词,你提到时自动投递;L3 带索引,模型自己会去翻 |
|
|
29
|
+
| 越存越乱、该忘的忘不掉 | `organize` 定期把散落的卡片合并成专题,`forgetting` 按半衰期让久不用的条目自己淡出——是真的归档,不是删掉 |
|
|
30
|
+
|
|
31
|
+
默认装在**只读影子模式**(shadow):能挂载、能看诊断,但不写盘、不注入、不发请求。要真启用得显式打开 active,并指定两个数据目录。
|
|
32
|
+
|
|
33
|
+
## 快速开始
|
|
34
|
+
|
|
35
|
+
### 安装
|
|
36
|
+
|
|
37
|
+
~~~powershell
|
|
38
|
+
dsh plugin --profile web add dsh-shiori
|
|
39
|
+
~~~
|
|
40
|
+
|
|
41
|
+
重启 DSH 后生效。插件以 DSH 原生 bundle 形式挂载(包内声明了 `dsh.bundle.patch`),不需要手改 `cordis.patch.yml`。
|
|
42
|
+
|
|
43
|
+
> 如果同时装着 `dsh-soul-md`,两者提供 9 个同名工具,宿主的「工具唯一提供者」校验会直接拒绝。先停用其中一个。
|
|
44
|
+
|
|
45
|
+
### 从源码安装
|
|
46
|
+
|
|
47
|
+
~~~powershell
|
|
48
|
+
npm pack # 得到 dsh-shiori-0.2.0.tgz
|
|
49
|
+
dsh plugin --profile web add <你的项目绝对路径>/dsh-shiori-0.2.0.tgz
|
|
50
|
+
~~~
|
|
51
|
+
|
|
52
|
+
### 第一次配置
|
|
53
|
+
|
|
54
|
+
装上之后是 **inert shadow**:挂载成功,面板显示 `needs-configuration`,但什么都不读写。要到插件详情页「预算」tab 或 profile 的 `cordis.patch.yml` 里补三项:
|
|
55
|
+
|
|
56
|
+
~~~yaml
|
|
57
|
+
- id: shiori
|
|
58
|
+
name: dsh-shiori
|
|
59
|
+
config:
|
|
60
|
+
mode: active
|
|
61
|
+
allowActive: true
|
|
62
|
+
dataRoot: '<你的记忆目录绝对路径>/shiori-data'
|
|
63
|
+
stateRoot: '<你的记忆目录绝对路径>/shiori-state'
|
|
64
|
+
~~~
|
|
65
|
+
|
|
66
|
+
- `dataRoot` 存记忆本身(人设卡、core、专题、卡片库)
|
|
67
|
+
- `stateRoot` 存运行账本(幂等记录、投递账、计划、锁)
|
|
68
|
+
- 两者必须是**绝对路径**、**互不嵌套**,缺一个就不动
|
|
69
|
+
|
|
70
|
+
`mode` 不改、只给两个根,就是 shadow 只读:面板能预览模型真实看到的内容(L0 / L1 / 索引),一个字节都不写。适合先看看效果再决定。
|
|
71
|
+
|
|
72
|
+
### 数据放在哪
|
|
73
|
+
|
|
74
|
+
数据全部在 `dataRoot` / `stateRoot`,**住在包外面**。升级、重装、卸载都不会碰它们。
|
|
75
|
+
|
|
76
|
+
## 核心工作机制
|
|
77
|
+
|
|
78
|
+
一次模型调用,插件做三件事:往开头摆好 L0/L1,扫你新说的话有没有命中 L2 卡,然后把命中的卡片作为一条独立附件塞进上下文。
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
┌─ L0 人设卡 ─┐
|
|
82
|
+
每轮注入 ────────┤ ├──→ 系统提示词
|
|
83
|
+
└─ L1 核心+索引┘
|
|
84
|
+
|
|
85
|
+
你说了句话 ──→ 触发词匹配 ──→ 0 跳种子(≤3 张)
|
|
86
|
+
└→ 沿连线/实体扩一跳(≤2 张)
|
|
87
|
+
└→ 拼成一条附件消息 → 进上下文
|
|
88
|
+
|
|
89
|
+
模型想知道某件事 ──→ memory_search / memory_read(topic) ──→ 读到全文
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
<details>
|
|
93
|
+
<summary><b>点此展开:几个会反复出现的词</b></summary>
|
|
94
|
+
|
|
95
|
+
| 词 | 意思 |
|
|
96
|
+
| --- | --- |
|
|
97
|
+
| **scope** | 一套独立记忆的命名空间。按会话 → 工作区 → 默认人设卡 → `global` 的顺序解析,越具体越优先。换工作区就等于换了一本笔记本 |
|
|
98
|
+
| **shadow / active** | shadow 是只读影子:什么都不写;active 才注册工具、写盘、注入。切换要显式加 `allowActive: true`,防止手滑 |
|
|
99
|
+
| **inert** | 两个根目录都没给的状态:插件挂载了但什么都不做,只报一条 `needs-configuration` 诊断 |
|
|
100
|
+
| **派生索引** | 由 L3 专题自动生成的一行行目录(`- key [scope] — 摘要`),跟 L1 正文一起进上下文。它不属于 core 正文,改写 core 时会自动重算 |
|
|
101
|
+
| **下沉** | L1 超过软目标后,把细节搬进 L3 专题、索引里只留一行的动作。原文不会丢 |
|
|
102
|
+
| **epoch** | 「这一轮对话的生命期」。记忆被压缩后 epoch +1,L2 的「这张卡已经投过」冷却全部作废,同一张卡在新一轮里可以再浮上来 |
|
|
103
|
+
| **operationId** | 所有写工具的幂等键。同一个 id 重试只会得到第一次的结果,不会写两遍 |
|
|
104
|
+
| **CAS / revision** | 每次写入都带一个版本记号,改之前先核对,过期的改写会被拒绝而不是覆盖——两个人(或两个会话)同时改同一份记忆时,不会互相吃掉 |
|
|
105
|
+
|
|
106
|
+
</details>
|
|
107
|
+
|
|
108
|
+
## 核心功能
|
|
109
|
+
|
|
110
|
+
### 分层记忆与预算
|
|
111
|
+
|
|
112
|
+
- **L0 人设卡**:整卡替换,写入超过上限直接拒。它可以是纯文本,也可以按会话 / 工作区分别指定不同的卡。
|
|
113
|
+
- **L1 记忆核心**:一段会随对话生长的正文。有软目标(超过就提示该压缩)和硬上限(真超了**绝不截断规则**,而是退回上一次可用的投影;连投影都没有就输出一段英文诊断占位,让你一眼看见出了问题)。
|
|
114
|
+
- **L3 专题**:一个主题一个文件,前面有 front-matter(key / 标题 / 摘要 / 更新时间),正文随便写多长。它不占提示词预算,只占索引一行。
|
|
115
|
+
- **编排权在模型手里**:什么时候追加、什么时候下沉、下沉到哪个专题,都由模型在工具调用里自己决定——插件只负责守住预算和一致性。
|
|
116
|
+
|
|
117
|
+
### Spark 闪回
|
|
118
|
+
|
|
119
|
+
- 卡片存的是**一条一条的原子记忆**:一句话、一个外号、一个约定。每张带 `triggers`(能唤醒它的原话)。
|
|
120
|
+
- 匹配是**字面匹配**,不做语义联想:NFC 归一化、英文大小写折叠;纯英文单词按词边界(`cat` 不会命中 `concatenate`),中文按子串。
|
|
121
|
+
- 命中的卡片连同它的一跳关联(沿显式连线、共同实体)拼成一条附件消息,标注来源是记忆插件,不打断正在进行的对话。
|
|
122
|
+
- **防刷屏**:同一会话同一 epoch 内,同一张卡只投一次;记忆被压缩后 epoch 加一,旧冷却自动失效。
|
|
123
|
+
- 卡片带生命期:`vitality: evergreen` 永不衰减,`ephemeral` 按半衰期慢慢淡。你或模型明确说「用了」会续命。
|
|
124
|
+
|
|
125
|
+
### 整理与遗忘
|
|
126
|
+
|
|
127
|
+
- **organize(整理)**:分析出三类候选——同一实体下堆积的卡片(cluster,够 8 张才提)、孤立无连线的卡片(isolated)、该连还没连的两张卡(link)。候选先给你看,确认后才生成不可变计划,执行前还要 diff 预览和一次显式确认。
|
|
128
|
+
- **forgetting(遗忘)**:分数 `2^(-闲置天数 / 半衰期)`,半衰期随使用次数从 30 天最长涨到 240 天。归档要四个条件全满足:是 active、是 ephemeral、没被别的卡替代、闲置 ≥ 61 天且分数低于阈值。**归档不是删除**,卡片还在库里,Cold 检索照样能查到。
|
|
129
|
+
|
|
130
|
+
### 原生 web 面板
|
|
131
|
+
|
|
132
|
+
入口:插件管理器 → dsh-shiori 详情页。六个 tab,操作全在界面上:
|
|
133
|
+
|
|
134
|
+
| tab | 用来干什么 |
|
|
135
|
+
| --- | --- |
|
|
136
|
+
| **状态** | 五行中文摘要(运行模式 / 当前作用域 / 服务是否起来 / 人设卡与记忆核心占用)+ 能力标记;原始字段收在「技术细节」里 |
|
|
137
|
+
| **记忆 L0/L1** | 看模型真实看到的内容,两层都能就地编辑保存(保存带版本校验) |
|
|
138
|
+
| **图谱** | Spark 卡片的节点与连线,拖拽平移、滚轮缩放、点开卡片改内容或加/减连线 |
|
|
139
|
+
| **候选 / 计划** | 跑整理分析、审阅候选、预览 diff、确认执行;合并记忆的主战场 |
|
|
140
|
+
| **L3 主题** | 主题列表默认只露 key / 标题 / 字数,展开读正文、整篇编辑保存 |
|
|
141
|
+
| **预算** | 十个中文字段,带参数名与上限提示;改完要重启生效 |
|
|
142
|
+
|
|
143
|
+
所有 tab 共用顶部的**工作区 → 会话**两级选择:先选工作区,再选那个工作区下的会话。面板看的就是你选中的那个会话的记忆。
|
|
144
|
+
|
|
145
|
+
### 幂等写入
|
|
146
|
+
|
|
147
|
+
所有写工具都收 `operationId`。网络抖动、宿主重试、模型重复调用同一个操作时,只会生效一次——重复的那次拿到的是第一次的结果。跨多个目录的写入走日志式事务,中途崩了下次启动会接着做完或整笔作废,不会留下半个状态。
|
|
148
|
+
|
|
149
|
+
## 常见问题
|
|
150
|
+
|
|
151
|
+
| 症状 | 原因与解法 |
|
|
152
|
+
| --- | --- |
|
|
153
|
+
| 面板显示「shadow 模式,数据界面停用」 | 配置还是 shadow 或 inert。补 `mode: active` + `allowActive: true` + 两个绝对根,重启 |
|
|
154
|
+
| 面板整块空白 | 前端渲染出错,打开浏览器控制台(F12)看报错 |
|
|
155
|
+
| 会话下拉变成手填框 | 会话列表瞬时取不到,点「刷新」(内置自动重试);还不行就整页刷新 |
|
|
156
|
+
| `REVISION_CONFLICT` | 这份记忆被别处改过了。重新读一次拿新版本号再写,别硬改 |
|
|
157
|
+
| `LOCK_BUSY` | 同一个数据目录被两个宿主进程同时写(比如 web 和桌面版都开着)。只留一个 |
|
|
158
|
+
| 明明提到了卡却没投递 | L2 关了;触发词跟你的说法对不上;这张卡在本轮已经投过;或者它被判定成泛化标签不扩散。查 `stateRoot/l2/` 里的账 |
|
|
159
|
+
| 预算改了没效果 | 预算是**热提交、重启生效**——面板保存的是启动快照,重启后才是新值 |
|
|
160
|
+
| `UNSUPPORTED … disabled` | 对应的 `l2` / `organize` / `forgetting` 开关没开 |
|
|
161
|
+
| `legacy topics remain read-only` | 这个专题是旧版本写入的,服务端拒绝改写。新建一个专题再合并 |
|
|
162
|
+
| 工具报 `tool ownership conflict` | 和 `dsh-soul-md`(或别的记忆插件)撞了同名工具,停用其中一个 |
|
|
163
|
+
| 记忆核心变成一段英文诊断 | L1 超过硬上限且没有可用投影。抬高 `budgets.core`,或把细节下沉到专题 |
|
|
164
|
+
|
|
165
|
+
## 模型侧工具
|
|
166
|
+
|
|
167
|
+
十六个工具,模型自己调用,不需要你记:
|
|
168
|
+
|
|
169
|
+
| 工具 | 作用 |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `soul_read` / `soul_update` | 读 / 整卡替换人设卡(CAS) |
|
|
172
|
+
| `memory_read` | 无参=当前 L1 渲染;带 topic=该专题全文 |
|
|
173
|
+
| `memory_search` | 专题词法检索,只回 key / 标题 / 摘要(可查归档) |
|
|
174
|
+
| `memory_append` / `memory_rewrite` | 往 core 或专题追加带日期的片段 / 整段替换 |
|
|
175
|
+
| `core_write` | 只替换磁盘上的 core 正文(不含派生索引) |
|
|
176
|
+
| `memory_list_topics` / `topic_create` / `topic_append` | 列专题、建专题、往专题追加 |
|
|
177
|
+
| `spark_save` / `spark_read` / `spark_update` | 存卡、读卡、改卡(含连线) |
|
|
178
|
+
| `spark_forget` / `spark_feedback` / `spark_graph` | 归档或标记被替代 / 标记「用了」续命 / 读图谱 |
|
|
179
|
+
|
|
180
|
+
## 数据与安全
|
|
181
|
+
|
|
182
|
+
### 存什么
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
<dataRoot>/
|
|
186
|
+
persona/<scope>.md 人设卡
|
|
187
|
+
scopes/<scope>/core.md 记忆核心正文
|
|
188
|
+
scopes/<scope>/topics/<key>.md 专题(front-matter + 正文)
|
|
189
|
+
sparks/scopes/<scope>/sparks.json 卡片库
|
|
190
|
+
journal/ staging/ 跨目录写入的事务日志与暂存
|
|
191
|
+
<stateRoot>/
|
|
192
|
+
tool-ops/ 工具幂等账
|
|
193
|
+
l2/ L2 投递账(扫描 / 待确认 / 已确认 / 已投递 / 冷却)
|
|
194
|
+
plans/ 整理与遗忘的计划(不可变)
|
|
195
|
+
queues/ 候选队列快照
|
|
196
|
+
projections/ 上一次可用的 L1 等投影
|
|
197
|
+
completion-* 压缩探针与单写者锁
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
全部是**明文、可直接读**的 Markdown 与 JSON。没有数据库、没有二进制封装——坏了能手工看,也能拿脚本批量处理。
|
|
201
|
+
|
|
202
|
+
### 安全边界
|
|
203
|
+
|
|
204
|
+
- **默认什么都不做**:不配置就是 inert shadow,一个字节都不写。要写盘必须同时出现 `mode: active` 和 `allowActive: true`。
|
|
205
|
+
- **路径硬校验**:两个根必须绝对、互不嵌套,盘符根单独保护;越界的路径直接拒。
|
|
206
|
+
- **不静默覆盖**:所有改写都带版本校验,过期就报 `REVISION_CONFLICT` 让你重读,而不是把别人的改动盖掉。
|
|
207
|
+
- **不擅自删数据**:遗忘是**归档**,物理删除不在这套工具里;卸载只移除包,`dataRoot` / `stateRoot` 原样留着。
|
|
208
|
+
- **不改别人的提示词**:宿主如果有 `complete: true` 的 section 在前面,本插件的 L0/L1 会被宿主回填覆盖。插件探测到就干脆零注册,并在诊断里写 `completeShadowed`——如实报告,不假装自己在生效。
|
|
209
|
+
|
|
210
|
+
### 版本兼容
|
|
211
|
+
|
|
212
|
+
| 宿主 | Node | 状态 |
|
|
213
|
+
| --- | --- | --- |
|
|
214
|
+
| DSH `>=0.2.1-rc.2 <0.3.0` | `>=24` | 已实测 |
|
|
215
|
+
| 更早的 DSH | — | 未验证 |
|
|
216
|
+
|
|
217
|
+
## 卸载
|
|
218
|
+
|
|
219
|
+
~~~powershell
|
|
220
|
+
dsh plugin --profile web remove dsh-shiori
|
|
221
|
+
~~~
|
|
222
|
+
|
|
223
|
+
只移除包与挂载,**记忆数据一个字节都不动**。想彻底清干净就自己删 `dataRoot` / `stateRoot` 两个目录——插件不会替你做这件事。
|
|
224
|
+
|
|
225
|
+
## 版本更新
|
|
226
|
+
|
|
227
|
+
### v0.1.0 · 2026-10-29(首个公开版本)
|
|
228
|
+
|
|
229
|
+
从 alpha 转正。这一版把面板彻底重做了一遍:
|
|
230
|
+
|
|
231
|
+
- **状态页**换成五行中文摘要,技术字段收进折叠区——不用再看一屏参数猜自己装没装上
|
|
232
|
+
- **记忆 L0/L1 可就地编辑**,保存带版本校验;编辑框里是磁盘正文,不会把派生索引写回 core
|
|
233
|
+
- **图谱改用滚轮缩放**,点开卡片能改标题 / 摘要 / 正文 / 触发词 / 实体 / 重要度,连线增删可撤销
|
|
234
|
+
- **新增「L3 主题」页**:列表只看名字和字数,展开才读正文,整篇可编辑;旧版写入的专题标为只读
|
|
235
|
+
- **候选 / 计划页**显示卡片的标题而不只是编号
|
|
236
|
+
- **会话选择改成工作区 → 会话两级**
|
|
237
|
+
- 人设卡长度上限从 12000 提到 **60000** 字符
|
|
238
|
+
|
|
239
|
+
## 更多文档
|
|
240
|
+
|
|
241
|
+
| 文档 | 内容 |
|
|
242
|
+
| --- | --- |
|
|
243
|
+
| [使用指南](https://github.com/Kanadego/dsh-shiori/blob/main/docs/USAGE-GUIDE.md) | 配置项全表、面板逐 tab 说明、十六个工具、记忆机制、数据文件、日常维护、故障速查 |
|
|
244
|
+
| [安装指南](https://github.com/Kanadego/dsh-shiori/blob/main/docs/plugin/INSTALL.md) | npm / tgz 安装、首次配置、升级与卸载 |
|
|
245
|
+
| [面板与 RPC](https://github.com/Kanadego/dsh-shiori/blob/main/docs/plugin/client.md) | 面板数据来源、授权边界、宿主能力缺失时的降级行为 |
|
|
246
|
+
|
|
247
|
+
## 许可
|
|
248
|
+
|
|
249
|
+
[CC BY-NC-SA 4.0](LICENSE):署名 · 非商业性使用 · 相同方式共享。
|