@gezi-wen/dsh-mem 0.5.5

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.
@@ -0,0 +1,137 @@
1
+ /**
2
+ * dsh-mem — 手写 strict typert host manifest(对齐官方生成文件格式)。
3
+ * typert-loader 在插件挂载时读 package.json 的 exports["./typert"],
4
+ * import 本文件并把 TYPERT 注册进 ctx.typert.local(strict 定义)。
5
+ * schema 必须是 zod v4 实例(typert-loader 校验 "_zod" in schema)。
6
+ */
7
+ import { z } from 'zod'
8
+
9
+ // 文件名:与 host 侧 safeName 同一套底线 —— 非空、无路径分隔符与 Windows 非法字符、
10
+ // 以 .md 结尾、长度有界。(真正的目录逃逸防护仍在 host 侧 safeName。)
11
+ const fileNameSchema = z.string().min(1).max(255).regex(/^[^\\/:*?"<>|\u0000-\u001f]+\.md$/)
12
+ // 正文:512 KB 上限。理由是「记忆要塞进 system prompt」——现行 memory 目录最大一条 19 KB,
13
+ // 到半兆量级基本是写错了目标(贴了日志/代码进来)。与 lib/index.js 的 MAX_FILE_BYTES 一致。
14
+ const fileContentSchema = z.string().max(512 * 1024)
15
+
16
+ const starmapStarSchema = z.object({
17
+ 'file': z.string().readonly(),
18
+ 'kind': z.string().readonly(),
19
+ 'title': z.string().readonly(),
20
+ 'desc': z.string().readonly(),
21
+ 'bytes': z.number().readonly(),
22
+ 'mtimeMs': z.number().readonly(),
23
+ }).readonly()
24
+ const starmapListSchema = z.object({
25
+ 'count': z.number().readonly(),
26
+ 'stars': z.array(starmapStarSchema).readonly(),
27
+ }).readonly()
28
+ const starmapReadSchema = z.object({
29
+ 'name': z.string().readonly(),
30
+ 'content': z.string().readonly(),
31
+ }).readonly()
32
+
33
+ const fileSchema = z.object({
34
+ 'file': z.string().readonly(),
35
+ 'type': z.string().readonly(),
36
+ 'description': z.string().readonly(),
37
+ 'size': z.number().readonly(),
38
+ }).readonly()
39
+
40
+ const listResultSchema = z.array(fileSchema)
41
+ const readResultSchema = z.object({
42
+ 'name': z.string().readonly(),
43
+ 'content': z.string().readonly(),
44
+ }).readonly()
45
+ // 写/删失败不再抛异常,走 { ok: false, error } 分支:error 必须声明,否则 strict
46
+ // 校验会把它当未知字段剥掉,设置页只能看到一个没有原因的 ok:false。
47
+ const writeResultSchema = z.object({
48
+ 'ok': z.boolean().readonly(),
49
+ 'file': z.string().readonly(),
50
+ 'error': z.string().readonly().optional(),
51
+ }).readonly()
52
+ const deleteResultSchema = z.object({
53
+ 'ok': z.boolean().readonly(),
54
+ 'error': z.string().readonly().optional(),
55
+ }).readonly()
56
+
57
+ export const TYPERT = {
58
+ package: '@gezi-wen/dsh-mem',
59
+ face: 'host',
60
+ schemas: [],
61
+ invocations: [
62
+ {
63
+ id: '@gezi-wen/dsh-mem#memory/listFiles',
64
+ service: 'memory',
65
+ namespace: 'memory',
66
+ method: 'listFiles',
67
+ invocation: { kind: 'direct' },
68
+ parameters: [],
69
+ result: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#FileList', schema: listResultSchema, create: () => listResultSchema },
70
+ sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
71
+ },
72
+ {
73
+ id: '@gezi-wen/dsh-mem#memory/readFile',
74
+ service: 'memory',
75
+ namespace: 'memory',
76
+ method: 'readFile',
77
+ invocation: { kind: 'direct' },
78
+ parameters: [
79
+ { name: 'name', wire: 'name', source: 'json', codec: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#FileName', schema: fileNameSchema, create: () => fileNameSchema } },
80
+ ],
81
+ result: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#FileContent', schema: readResultSchema, create: () => readResultSchema },
82
+ sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
83
+ },
84
+ {
85
+ id: '@gezi-wen/dsh-mem#memory/writeFile',
86
+ service: 'memory',
87
+ namespace: 'memory',
88
+ method: 'writeFile',
89
+ invocation: { kind: 'direct' },
90
+ parameters: [
91
+ { name: 'name', wire: 'name', source: 'json', codec: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#FileName', schema: fileNameSchema, create: () => fileNameSchema } },
92
+ { name: 'content', wire: 'content', source: 'json', codec: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#FileContent', schema: fileContentSchema, create: () => fileContentSchema } },
93
+ ],
94
+ result: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#WriteResult', schema: writeResultSchema, create: () => writeResultSchema },
95
+ sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
96
+ },
97
+ {
98
+ id: '@gezi-wen/dsh-mem#memory/deleteFile',
99
+ service: 'memory',
100
+ namespace: 'memory',
101
+ method: 'deleteFile',
102
+ invocation: { kind: 'direct' },
103
+ parameters: [
104
+ { name: 'name', wire: 'name', source: 'json', codec: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#FileName', schema: fileNameSchema, create: () => fileNameSchema } },
105
+ ],
106
+ result: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#DeleteResult', schema: deleteResultSchema, create: () => deleteResultSchema },
107
+ sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
108
+ },
109
+ {
110
+ id: '@gezi-wen/dsh-mem#starmap/listStars',
111
+ service: 'starmap',
112
+ namespace: 'starmap',
113
+ method: 'listStars',
114
+ invocation: { kind: 'direct' },
115
+ parameters: [],
116
+ result: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#StarmapList', schema: starmapListSchema, create: () => starmapListSchema },
117
+ sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
118
+ },
119
+ {
120
+ id: '@gezi-wen/dsh-mem#starmap/readFile',
121
+ service: 'starmap',
122
+ namespace: 'starmap',
123
+ method: 'readFile',
124
+ invocation: { kind: 'direct' },
125
+ parameters: [
126
+ { name: 'name', wire: 'name', source: 'json', codec: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#FileName', schema: fileNameSchema, create: () => fileNameSchema } },
127
+ ],
128
+ result: { mode: 'strict', typeSymbol: '@gezi-wen/dsh-mem/types#StarmapRead', schema: starmapReadSchema, create: () => starmapReadSchema },
129
+ sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
130
+ },
131
+ ],
132
+ model: {
133
+ "services": [],
134
+ "events": [],
135
+ "objects": [],
136
+ },
137
+ }
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@gezi-wen/dsh-mem",
3
+ "description": "Cross-session memory plugin for DeepSeek Harness (dsh) — transparent markdown memory files with question-based recall and a memory star-map view in the web UI",
4
+ "version": "0.5.5",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./client": "./lib/client.js",
10
+ "./typert": "./lib/typert.host.js",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "lib/index.js",
15
+ "lib/client.js",
16
+ "lib/typert.host.js",
17
+ "cordis.patch.yml",
18
+ "NOTICE"
19
+ ],
20
+ "license": "Apache-2.0",
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "dsh": {
25
+ "bundle": {
26
+ "patch": "./cordis.patch.yml"
27
+ },
28
+ "client": {
29
+ "platform": "web",
30
+ "inject": [
31
+ "@deepseek-ai/dsh-client-locale"
32
+ ]
33
+ },
34
+ "compatibility": {
35
+ "dsh": ">=0.1.2-rc.1",
36
+ "dshReleases": {
37
+ "0.1.2-rc.1": "compatible",
38
+ "0.1.3-alpha.1": "compatible",
39
+ "0.1.3-alpha.2": "compatible",
40
+ "0.1.5-rc.1": "compatible",
41
+ "0.1.6-alpha.1": "compatible",
42
+ "0.1.6-alpha.2": "compatible",
43
+ "0.1.7-rc.1": "compatible",
44
+ "0.1.7-rc.2": "compatible"
45
+ }
46
+ }
47
+ },
48
+ "dependencies": {
49
+ "zod": "^4.4.3"
50
+ },
51
+ "peerDependencies": {
52
+ "@deepseek-ai/cordis": "^4.0.2",
53
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.2-rc.1",
54
+ "@deepseek-ai/dsh-client-locale": "^0.1.2-rc.1",
55
+ "react": "^18.0.0"
56
+ },
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "git+https://github.com/gezi-wen/dsh-mem.git"
60
+ },
61
+ "homepage": "https://github.com/gezi-wen/dsh-mem#readme",
62
+ "bugs": {
63
+ "url": "https://github.com/gezi-wen/dsh-mem/issues"
64
+ },
65
+ "keywords": [
66
+ "memory",
67
+ "ai-memory",
68
+ "agent-memory",
69
+ "long-term-memory",
70
+ "cross-session-memory",
71
+ "context-management",
72
+ "knowledge-management",
73
+ "markdown",
74
+ "dsh",
75
+ "dsh-plugin",
76
+ "deepseek",
77
+ "deepseek-harness",
78
+ "cordis",
79
+ "typert",
80
+ "plugin",
81
+ "ai-agent",
82
+ "agent",
83
+ "claude-code"
84
+ ]
85
+ }