dsh-instruction-memory 1.1.0 → 1.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/CHANGELOG.md +107 -0
- package/README.md +171 -14
- package/lib/client.js +864 -2
- package/lib/index.js +1362 -74
- package/memory.schema.json +167 -0
- package/package.json +3 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://github.com/HERO476/dsh-instruction-memory/memory.schema.json",
|
|
4
|
+
"title": "dsh-instruction-memory 存储文件",
|
|
5
|
+
"description": "DSH「指令记忆」插件的存储文件(memory.json)。默认位于 <DSH_HOME>/instruction-memory/memory.json。手改此文件时把 \"$schema\" 指向本文件即可获得编辑器的字段校验与补全;宿主也会把本文件的副本放在 memory.json 旁边,因此 \"$schema\": \"./memory.schema.json\" 开箱即用。注意:本 Schema 只校验文件形状与长度上限,**不校验**语义——例如指向不存在配置集的 setId 不会被这里报错,而是在载入时按规则修正并在设置页披露。",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [],
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "本文件的 Schema 引用。宿主写入时固定为 ./memory.schema.json(与 memory.json 同目录的那份副本)。"
|
|
12
|
+
},
|
|
13
|
+
"version": {
|
|
14
|
+
"type": "integer",
|
|
15
|
+
"enum": [1, 2],
|
|
16
|
+
"description": "存储格式版本。1 = 单套记忆(无配置集);2 = 引入配置集(sets / activeSetId / setId)。缺失视为 1。其它数字会被插件拒绝载入并暂停修改,以防数据损坏。",
|
|
17
|
+
"default": 2
|
|
18
|
+
},
|
|
19
|
+
"rev": {
|
|
20
|
+
"type": "integer",
|
|
21
|
+
"minimum": 0,
|
|
22
|
+
"description": "存储修订号,由插件在每次成功写入时递增并落盘,用于多窗口/多进程的冲突拒绝。请勿手填。",
|
|
23
|
+
"default": 0
|
|
24
|
+
},
|
|
25
|
+
"enabled": {
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"description": "总开关。为 false 时指令与用户形象都不注入。",
|
|
28
|
+
"default": true
|
|
29
|
+
},
|
|
30
|
+
"budgetChars": {
|
|
31
|
+
"type": "integer",
|
|
32
|
+
"minimum": 800,
|
|
33
|
+
"maximum": 40000,
|
|
34
|
+
"description": "指令注入字数上限(字符,非 token)。超出部分按优先级取舍,未注入的条目会在设置页标记。用户形象不占用此上限。",
|
|
35
|
+
"default": 4000
|
|
36
|
+
},
|
|
37
|
+
"backupDir": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"maxLength": 512,
|
|
40
|
+
"description": "自定义备份位置(绝对路径)。留空表示与存储文件同目录。它决定版本快照目录与「另存到备份目录」的去向;存储文件本身与它的跨进程锁不会移动。这是**本机设置**,从备份文件恢复时不会被改写。",
|
|
41
|
+
"default": ""
|
|
42
|
+
},
|
|
43
|
+
"activeSetId": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "当前激活的配置集 id。只有它包含的条目与用户形象会被注入。缺失或指向不存在的配置集时,插件回退到 sets 中的第一个集合并予以披露;插件**绝不**根据工作目录(cwd)自动创建或切换配置集。",
|
|
46
|
+
"default": "st-default"
|
|
47
|
+
},
|
|
48
|
+
"sets": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"maxItems": 20,
|
|
51
|
+
"description": "配置集列表。每个配置集只有 id 与名称,内容由 entries / profiles 的 setId 指向,因此「切换配置集」不会移动任何一条用户文本。缺失或为空时,插件会合成一个名为「默认」的集合,并把所有条目归入其中(旧版文件即由此平滑迁移)。",
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"required": ["id", "name"],
|
|
55
|
+
"properties": {
|
|
56
|
+
"id": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"description": "配置集 id,条目与用户形象通过 setId 引用它。"
|
|
59
|
+
},
|
|
60
|
+
"name": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"maxLength": 30,
|
|
63
|
+
"description": "配置集名称(单行,最多 30 字符)。"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"default": [{ "id": "st-default", "name": "默认" }]
|
|
68
|
+
},
|
|
69
|
+
"entries": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"maxItems": 200,
|
|
72
|
+
"description": "指令条目。全部配置集合计最多 200 条;超出的条目在载入时会被剔除并明确披露(下次保存即从文件中移除)。",
|
|
73
|
+
"items": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"properties": {
|
|
76
|
+
"id": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "条目 id(插件生成,形如 im-xxxx)。缺失或重复时载入时会补发新 id。"
|
|
79
|
+
},
|
|
80
|
+
"title": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"maxLength": 120,
|
|
83
|
+
"description": "标题(单行,最多 120 字符)。与内容同时为空时该条目会被剔除。留空时自动取内容前 40 字符。"
|
|
84
|
+
},
|
|
85
|
+
"content": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"maxLength": 6000,
|
|
88
|
+
"description": "指令正文,最多 6000 字符。超长会被截断并在设置页披露。"
|
|
89
|
+
},
|
|
90
|
+
"mode": {
|
|
91
|
+
"type": "string",
|
|
92
|
+
"enum": ["always", "auto"],
|
|
93
|
+
"description": "生效方式:always = 无条件遵守;auto = 由模型按相关性判断,配合 when 描述适用场景。",
|
|
94
|
+
"default": "always"
|
|
95
|
+
},
|
|
96
|
+
"when": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"maxLength": 200,
|
|
99
|
+
"description": "适用场景(单行,最多 200 字符),仅对 mode=auto 有意义;写清楚有助于模型判断何时生效。"
|
|
100
|
+
},
|
|
101
|
+
"priority": {
|
|
102
|
+
"type": "integer",
|
|
103
|
+
"enum": [0, 1, 2],
|
|
104
|
+
"description": "优先级:2 高 / 1 普通 / 0 低。超出注入字数上限时按优先级保留。",
|
|
105
|
+
"default": 1
|
|
106
|
+
},
|
|
107
|
+
"enabled": {
|
|
108
|
+
"type": "boolean",
|
|
109
|
+
"description": "是否启用该条目。",
|
|
110
|
+
"default": true
|
|
111
|
+
},
|
|
112
|
+
"tags": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"maxItems": 8,
|
|
115
|
+
"description": "标签:仅用于设置页分组与筛选,**不会**进入注入文本,也不影响注入顺序与取舍。",
|
|
116
|
+
"items": { "type": "string", "maxLength": 24 }
|
|
117
|
+
},
|
|
118
|
+
"setId": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"description": "所属配置集 id。指向不存在的配置集时会归入当前激活集合并披露;留空视为「跟随当前激活集合」。"
|
|
121
|
+
},
|
|
122
|
+
"updatedAt": {
|
|
123
|
+
"type": "integer",
|
|
124
|
+
"description": "最近更新时间(epoch 毫秒),由插件维护;同一优先级内按它倒序注入,以保持提示词前缀稳定。"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"profiles": {
|
|
130
|
+
"type": "array",
|
|
131
|
+
"maxItems": 50,
|
|
132
|
+
"description": "用户形象:关于**用户本人**的身份背景、喜好、性格与追求。它们不参与指令字数上限,始终完整注入,并带有一段「仅供调整表达侧重、不得为迎合而改变事实」的护栏说明;形象不是让模型扮演的角色。",
|
|
133
|
+
"items": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"properties": {
|
|
136
|
+
"id": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"description": "形象 id(插件生成,形如 im-xxxx)。"
|
|
139
|
+
},
|
|
140
|
+
"name": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"maxLength": 40,
|
|
143
|
+
"description": "短标签(单行,最多 40 字符),如「职业背景」「沟通偏好」。留空时取内容前 20 字符。"
|
|
144
|
+
},
|
|
145
|
+
"content": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"maxLength": 4000,
|
|
148
|
+
"description": "形象描述,最多 4000 字符。"
|
|
149
|
+
},
|
|
150
|
+
"enabled": {
|
|
151
|
+
"type": "boolean",
|
|
152
|
+
"description": "是否使用该形象;不勾选时完全不注入。",
|
|
153
|
+
"default": true
|
|
154
|
+
},
|
|
155
|
+
"setId": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"description": "所属配置集 id;规则与指令条目相同。"
|
|
158
|
+
},
|
|
159
|
+
"updatedAt": {
|
|
160
|
+
"type": "integer",
|
|
161
|
+
"description": "最近更新时间(epoch 毫秒)。"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-instruction-memory",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "User-only instruction memory for DSH: long-term instructions maintained in the settings UI and auto-injected into every conversation — the model has no write access. 指令记忆:只由用户在设置页维护的长期指令,自动注入此后每轮对话;模型没有任何写入口。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"README.md",
|
|
30
30
|
"CHANGELOG.md",
|
|
31
31
|
"LICENSE",
|
|
32
|
+
"memory.schema.json",
|
|
32
33
|
"docs/screenshot.png"
|
|
33
34
|
],
|
|
34
35
|
"keywords": [
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"author": "huangpeiyan",
|
|
58
59
|
"scripts": {
|
|
59
60
|
"lint": "node lint.mjs",
|
|
60
|
-
"test": "node lint.mjs && node host-range-test.mjs && node smoke-test.mjs && node contract-test.mjs && node verify.mjs",
|
|
61
|
+
"test": "node lint.mjs && node host-range-test.mjs && node smoke-test.mjs && node contract-test.mjs && node verify.mjs && node ui-test.mjs",
|
|
61
62
|
"prepublishOnly": "node check-metadata.mjs"
|
|
62
63
|
},
|
|
63
64
|
"dsh": {
|