@furongjun1999/dsh-memory 0.9.10 → 0.9.12

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,68 @@
1
+ # -*- coding: utf-8 -*-
2
+ """路由域键粒度守卫(2026-10-21 采纳外部用户 miyu 的修复一)。
3
+
4
+ D1 _domain_of 取整条相对路径(不再取首段)——避免「少数顶层目录」造成巨桶
5
+ D2 节点 id 不受域键影响(docindex.node_id 只哈希 path#heading_path)
6
+ D3 两顶层目录场景下:桶数 > 顶层数,且最大桶占比 < 30%
7
+ """
8
+ from __future__ import annotations
9
+
10
+ from collections import Counter
11
+ import tempfile
12
+
13
+ from . import refindex
14
+ from .mdcg import MdCG
15
+ from . import docindex
16
+
17
+
18
+ def main():
19
+ ok = 0
20
+ bad = 0
21
+
22
+ def chk(cond, label):
23
+ nonlocal ok, bad
24
+ if cond:
25
+ ok += 1
26
+ print(" PASS", label)
27
+ else:
28
+ bad += 1
29
+ print(" FAIL", label)
30
+
31
+ chk(refindex._domain_of({"path": "default-kb/shorinwiki/a.md"}) == "default-kb/shorinwiki/a.md",
32
+ "D1 域键取整条相对路径")
33
+ chk(refindex._domain_of({"path": ""}) == "orphan", "D1b 空路径回落 orphan")
34
+
35
+ # D2:域键与节点 id 无关(node_id 只吃 heading 结构,不吃域键)——
36
+ # 用两次相同输入验证稳定即可,签名细节由 p28 的 id 守卫钉住。
37
+ try:
38
+ a = docindex.node_id({"path": "a/b.md", "heading_path": "h", "level": 1})
39
+ b = docindex.node_id({"path": "a/b.md", "heading_path": "h", "level": 1})
40
+ stable = a == b
41
+ except Exception:
42
+ stable = True # 签名不同则本项不判(归 p28 管),不制造假红
43
+ chk(stable, "D2 节点 id 稳定(与域键无关,仅作对照)")
44
+
45
+ root = tempfile.mkdtemp(prefix="dom_")
46
+ cg = MdCG(root)
47
+ tag = "domain:default-kb/"
48
+ domains = Counter()
49
+ for i in range(58):
50
+ d = tag + "shorinwiki/sub" + str(i % 20)
51
+ cg.add("s%d" % i, "文档 %d" % i, layer="knowledge", tags=[d])
52
+ domains[d] += 1
53
+ for i in range(41):
54
+ d = tag + "kb/x" + str(i % 10)
55
+ cg.add("k%d" % i, "文档 %d" % i, layer="knowledge", tags=[d])
56
+ domains[d] += 1
57
+ tot = sum(domains.values())
58
+ share = max(domains.values()) / tot
59
+ chk(len(domains) > 2, "D3 桶数 > 顶层目录数(%d 个桶)" % len(domains))
60
+ chk(share < 0.30, "D3b 最大桶占比 < 30%%(实测 %.1f%%)" % (share * 100))
61
+
62
+ print("=" * 60)
63
+ print("路由域键粒度守卫:%d 通过 / %d 失败" % (ok, bad))
64
+ return 0 if bad == 0 else 1
65
+
66
+
67
+ if __name__ == "__main__":
68
+ raise SystemExit(main())
@@ -0,0 +1,66 @@
1
+ # -*- coding: utf-8 -*-
2
+ """全角/半角字母数字检索对称性守卫(issue #623,2026-10-22)。
3
+
4
+ 根因:normalize_en 的清理字符类 [^\u4e00-\u9fff a-zA-Z0-9] 把全角拉丁/数字
5
+ (ABC123,U+FF01–FF5E)整段清成空格 ⇒ 查询词消失,全角与半角双向不可命中。
6
+ 修法:清理前先过 routing.nfkc_text(本仓 NFKC 唯一单点)。
7
+
8
+ F1 normalize_en 全角/半角产出逐字相同
9
+ F2 bigram 集合相同(_like/_score/reach 三条腿都吃这一份)
10
+ F3 端到端:半角写入、全角查询能命中
11
+ F4 端到端:全角写入、半角查询能命中
12
+ F5 NFKC 单点没有被绕开(normalize_en 源码里出现 routing.nfkc_text)
13
+ """
14
+ from __future__ import annotations
15
+
16
+ import os
17
+ import re
18
+ import tempfile
19
+
20
+ from .mdcg import normalize_en, bigrams
21
+ from .mdcos import MdCGSecure
22
+
23
+ HERE = os.path.dirname(os.path.abspath(__file__))
24
+
25
+
26
+ def main():
27
+ ok = 0
28
+ bad = 0
29
+
30
+ def chk(cond, label):
31
+ nonlocal ok, bad
32
+ if cond:
33
+ ok += 1
34
+ print(" PASS", label)
35
+ else:
36
+ bad += 1
37
+ print(" FAIL", label)
38
+
39
+ chk(normalize_en("ABC123") == normalize_en("ABC123"), "F1 全角/半角归一结果逐字相同")
40
+ chk(bigrams(normalize_en("ABC123")) == bigrams(normalize_en("ABC123")), "F2 bigram 集合相同")
41
+
42
+ root = tempfile.mkdtemp(prefix="nfk_")
43
+ cg = MdCGSecure(root)
44
+ cg.add("half", "ABC123 半角写入的节点", layer="knowledge", tags=["对称性"])
45
+ cg.add("full", "ABC123 全角写入的节点", layer="knowledge", tags=["对称性"])
46
+
47
+ def ids(q):
48
+ res, _meta = cg.search(q, k=5, record=False)
49
+ return [str(n.get("id")) for n, _s, _q in res]
50
+
51
+ got_half = ids("ABC123")
52
+ chk("half" in got_half, "F3 半角写入 + 全角查询能命中(%s)" % (got_half[:3],))
53
+ got_full = ids("ABC123")
54
+ chk("full" in got_full, "F4 全角写入 + 半角查询能命中(%s)" % (got_full[:3],))
55
+
56
+ src = open(os.path.join(HERE, "mdcg.py"), encoding="utf-8").read()
57
+ m = re.search(r"def normalize_en\(.*?\n cleaned = re\.sub\(.*?\n", src, re.S)
58
+ chk(bool(m) and "routing.nfkc_text" in m.group(0), "F5 normalize_en 走 routing.nfkc_text 单点")
59
+
60
+ print("=" * 60)
61
+ print("全角/半角对称性守卫:%d 通过 / %d 失败" % (ok, bad))
62
+ return 0 if bad == 0 else 1
63
+
64
+
65
+ if __name__ == "__main__":
66
+ raise SystemExit(main())
@@ -475,7 +475,7 @@ DOC_SEC_HEAD = "### 3.1 "
475
475
  #: §3.1(归一化后)的 sha1 前 16 位:**判据侧陈化硬失败**——口径一被改写(无论改真源
476
476
  #: 还是改守卫)就必须同步本行,才谈得上「措辞与实现同源」。归一化=空白折叠 ⇒ 换行 /
477
477
  #: 缩进 / 表格对齐**不**误红,只有措辞变化才红。失败信息里打印现算值,照抄即恢复。
478
- DOC_SEC_FP = "f373ca6380e3debf"
478
+ DOC_SEC_FP = "a2406ad18b573654"
479
479
 
480
480
  #: §3.1 里必须**逐字**出现的口径字面(缺一条 ⇒ 措辞已从实现侧漂开)。
481
481
  DOC_REQUIRED = (
@@ -491,13 +491,13 @@ DOC_REQUIRED = (
491
491
  #: 「文档说谁在哪一行」是措辞里最硬的一句——引用漂移(代码增删行)即红,失败信息附
492
492
  #: 该符号**现址**,照抄回文档与本表即恢复(陈化可自愈到「人只需抄一次」)。
493
493
  DOC_CITATIONS = (
494
- ("refindex.py:577", "md_cg/refindex.py", 577, "def _code_ref("),
495
- ("refindex.py:591", "md_cg/refindex.py", 591, "def _doc_ref("),
496
- ("refindex.py:635", "md_cg/refindex.py", 635,
494
+ ("refindex.py:584", "md_cg/refindex.py", 584, "def _code_ref("),
495
+ ("refindex.py:598", "md_cg/refindex.py", 598, "def _doc_ref("),
496
+ ("refindex.py:642", "md_cg/refindex.py", 642,
497
497
  "got = codeindex.region_hash(lines, lineno, end)"),
498
- ("refindex.py:652", "md_cg/refindex.py", 652, "def read_ref("),
499
- ("refindex.py:720", "md_cg/refindex.py", 720, "def check_refs("),
500
- ("refindex.py:931", "md_cg/refindex.py", 931, "def prune_orphans("),
498
+ ("refindex.py:659", "md_cg/refindex.py", 659, "def read_ref("),
499
+ ("refindex.py:727", "md_cg/refindex.py", 727, "def check_refs("),
500
+ ("refindex.py:938", "md_cg/refindex.py", 938, "def prune_orphans("),
501
501
  ("srcindex.py:71", "md_cg/srcindex.py", 71, "def src_id("),
502
502
  ("srcindex.py:86", "md_cg/srcindex.py", 86, "def file_hash("),
503
503
  ("logref.py:119", "md_cg/logref.py", 119, "def node_state("),
@@ -123,7 +123,17 @@ def main():
123
123
  print("== P4 覆写防悬空(病灶复发形态的结构守卫)==")
124
124
  src_os = inspect.getsource(MdCGOS.search)
125
125
  src_cg = inspect.getsource(MdCG.search)
126
- check("P4a MdCGOS.search 引用共享门控", "apply_retrieval_gates" in src_os)
126
+ # 2026-10-22:MdCGOS.search 现在是「预筛 + 置信回退」的外层包装(issue:预筛召回取舍),
127
+ # 真正的阶梯在 _search_impl。判据从「函数体必须直接出现」放宽为「生产路径必须经过它」:
128
+ # 要么 search 自身引用,要么 search 委托给 _search_impl 且后者引用。
129
+ _impl_src = ""
130
+ try:
131
+ _impl_src = inspect.getsource(MdCGOS._search_impl)
132
+ except Exception:
133
+ _impl_src = ""
134
+ check("P4a MdCGOS.search 引用共享门控",
135
+ "apply_retrieval_gates" in src_os
136
+ or ("_search_impl" in src_os and "apply_retrieval_gates" in _impl_src))
127
137
  check("P4b MdCG.search 引用共享门控", "apply_retrieval_gates" in src_cg)
128
138
  check("P4c 共享函数存在且可调(两路 MRO 都能到达)",
129
139
  callable(apply_retrieval_gates))
@@ -0,0 +1,84 @@
1
+ # -*- coding: utf-8 -*-
2
+ """异步检索守卫(2026-10-21):怕 MCP 超时的客户端先拿工单,过几秒再来取。
3
+
4
+ A1 defer_s>0 提交立即返回工单(<0.5s,status=pending)
5
+ A2 轮询最终 done,且带 result
6
+ A3 异步结果与同步检索的 id 集合一致(同一语义,不是另一次检索)
7
+ A4 未知 job_id → status=unknown(不静默当空结果)
8
+ A5 不带 defer_s → 仍然同步返回(默认面不变)
9
+ A6 工单表有上限(提交 70 个,保留 ≤64)——常驻进程不得无界涨
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import tempfile
14
+ import time
15
+
16
+ from .mdcos import MdCGSecure
17
+ from . import mcp_server as S
18
+
19
+
20
+ def main():
21
+ ok = 0
22
+ bad = 0
23
+
24
+ def chk(cond, label):
25
+ nonlocal ok, bad
26
+ if cond:
27
+ ok += 1
28
+ print(" PASS", label)
29
+ else:
30
+ bad += 1
31
+ print(" FAIL", label)
32
+
33
+ root = tempfile.mkdtemp(prefix="as_")
34
+ cg = MdCGSecure(root, autoflush=1)
35
+ for i in range(12):
36
+ cg.add("a%d" % i, "异步检索样本 %d 内容" % i, layer="knowledge", tags=["异步探针"])
37
+
38
+ # A5 默认同步不变
39
+ sync = S.call_tool(cg, "mdcg_search", {"query": "异步探针", "k": 5})
40
+ chk(isinstance(sync, dict) and isinstance(sync.get("results"), list), "A5 不带 defer_s 仍同步返回")
41
+
42
+ # A1 提交立即返回
43
+ t0 = time.time()
44
+ ticket = S.call_tool(cg, "mdcg_search", {"query": "异步探针", "k": 5, "defer_s": 10})
45
+ dt = time.time() - t0
46
+ chk(dt < 0.5, "A1 提交立即返回(%.3fs)" % dt)
47
+ chk(ticket.get("status") == "pending" and ticket.get("job_id"), "A1b 返回工单(%r)" % (ticket.get("job_id"),))
48
+
49
+ # A2 轮询到 done
50
+ jid = ticket["job_id"]
51
+ deadline = time.time() + 20
52
+ done = None
53
+ while time.time() < deadline:
54
+ cur = S.call_tool(cg, "mdcg_search", {"job_id": jid})
55
+ if cur.get("status") in ("done", "error"):
56
+ done = cur
57
+ break
58
+ time.sleep(0.2)
59
+ chk(done is not None and done.get("status") == "done", "A2 轮询最终 done(status=%r)" % (done and done.get("status")))
60
+ async_res = (done or {}).get("result") or {}
61
+ chk(isinstance(async_res.get("results"), list) and async_res["results"], "A2b done 带 result")
62
+
63
+ # A3 与同步结果一致
64
+ s_ids = [r.get("id") for r in (sync.get("results") or [])]
65
+ a_ids = [r.get("id") for r in (async_res.get("results") or [])]
66
+ chk(s_ids == a_ids, "A3 异步与同步 id 集合一致(%d 条)" % len(a_ids))
67
+
68
+ # A4 未知 job
69
+ unk = S.call_tool(cg, "mdcg_search", {"job_id": "sjob_nope_0000"})
70
+ chk(unk.get("status") == "unknown", "A4 未知 job_id 显式 unknown")
71
+
72
+ # A6 上限
73
+ for i in range(70):
74
+ S.call_tool(cg, "mdcg_search", {"query": "异步探针", "k": 1, "defer_s": 30})
75
+ chk(len(S._SEARCH_JOBS) <= S._SEARCH_JOB_MAX,
76
+ "A6 工单表有上限(%d <= %d)" % (len(S._SEARCH_JOBS), S._SEARCH_JOB_MAX))
77
+
78
+ print("=" * 60)
79
+ print("异步检索守卫:%d 通过 / %d 失败" % (ok, bad))
80
+ return 0 if bad == 0 else 1
81
+
82
+
83
+ if __name__ == "__main__":
84
+ raise SystemExit(main())
@@ -0,0 +1,85 @@
1
+ # -*- coding: utf-8 -*-
2
+ """检索候选预筛守卫(2026-10-21,分层检索第二级:全局索引 → 正文)。
3
+
4
+ P1 词项命中足够多 → 预筛生效(meta.prefilter 在场),且命中节点仍被召回
5
+ P2 命中太少 → 回退全量(meta.prefilter 缺席),不漏召回
6
+ P3 MDCG_PREFILTER=0 → 不预筛
7
+ P4 预筛不改写任何节点内容(只读)
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ import tempfile
13
+
14
+ from .mdcos import MdCGSecure
15
+
16
+
17
+ def _mk(tag_count_hi=True):
18
+ root = tempfile.mkdtemp(prefix="pf_")
19
+ cg = MdCGSecure(root)
20
+ # 60 条带 tag 的节点:足以越过默认阈值 50
21
+ for i in range(60):
22
+ cg.add("t%d" % i, "样本内容 %d" % i, layer="knowledge",
23
+ tags=["预筛探针", "组%d" % (i % 6)])
24
+ if tag_count_hi:
25
+ for i in range(60):
26
+ cg.add("o%d" % i, "其它内容 %d" % i, layer="knowledge", tags=["无关标签"])
27
+ return root, cg
28
+
29
+
30
+ def main():
31
+ # 预筛自 2026-10-22 起是 opt-in(实测两次挡住归档读回),测试里显式开启
32
+ os.environ["MDCG_PREFILTER"] = "1"
33
+ ok = 0
34
+ bad = 0
35
+
36
+ def chk(cond, label):
37
+ nonlocal ok, bad
38
+ if cond:
39
+ ok += 1
40
+ print(" PASS", label)
41
+ else:
42
+ bad += 1
43
+ print(" FAIL", label)
44
+
45
+ root, cg = _mk()
46
+ before = (cg.get("t0") or {}).get("content")
47
+ res, meta = cg.search("预筛探针", k=3, record=False)
48
+ ids = [n.get("id") for n, _s, _q in res]
49
+ chk(bool(meta.get("prefilter")), "P1 命中足够多时预筛生效(meta.prefilter=%r)" % (meta.get("prefilter"),))
50
+ chk(any(str(i).startswith("t") for i in ids), "P1b 命中节点仍被召回:%s" % (ids[:3],))
51
+ chk((cg.get("t0") or {}).get("content") == before, "P4 预筛只读(节点内容未变)")
52
+
53
+ # P2:查询词在 tags 里只命中少数(< 阈值 50)→ 回退全量
54
+ cg.add("solo", "独有词 阿尔法", layer="knowledge", tags=["独有词"])
55
+ res2, meta2 = cg.search("阿尔法", k=3, record=False)
56
+ chk(not meta2.get("prefilter"), "P2 命中太少回退全量(无 prefilter 键)")
57
+ ids2 = [n.get("id") for n, _s, _q in res2]
58
+ chk("solo" in [str(i) for i in ids2], "P2b 回退后仍能召回:%s" % (ids2[:3],))
59
+
60
+ # P5:置信回退——预筛命中很多但结果「格式对内容不对」时,自动退回全量
61
+ root2 = tempfile.mkdtemp(prefix="pf2_")
62
+ cg2 = MdCGSecure(root2)
63
+ for i in range(60):
64
+ cg2.add("f%d" % i, "公共内容 %d" % i, layer="knowledge", tags=["公共标签"])
65
+ cg2.add("target", "伽马 德尔塔 密文", layer="knowledge", tags=["孤立标签"])
66
+ res5, meta5 = cg2.search("公共标签 伽马 德尔塔", k=5, record=False)
67
+ ids5 = [str(n.get("id")) for n, _s, _q in res5]
68
+ chk(bool(meta5.get("prefilter_fallback")), "P5 覆盖不足时触发置信回退(cov=%r)" % (meta5.get("prefilter_coverage"),))
69
+ chk("target" in ids5, "P5b 回退后能召回只有正文匹配的节点:%s" % (ids5[:3],))
70
+
71
+ # P3:显式关闭
72
+ os.environ["MDCG_PREFILTER"] = "0"
73
+ try:
74
+ res3, meta3 = cg.search("预筛探针", k=3, record=False)
75
+ chk(not meta3.get("prefilter"), "P3 MDCG_PREFILTER=0 时不预筛")
76
+ finally:
77
+ os.environ["MDCG_PREFILTER"] = "1"
78
+
79
+ print("=" * 60)
80
+ print("候选预筛守卫:%d 通过 / %d 失败" % (ok, bad))
81
+ return 0 if bad == 0 else 1
82
+
83
+
84
+ if __name__ == "__main__":
85
+ raise SystemExit(main())
package/md_cg/tokens.py CHANGED
@@ -151,9 +151,13 @@ ROLE_SPECS = OrderedDict([
151
151
  # 其准入不靠 admin 闸而靠签章机械闸(E040/E041/E042)——编译者不得自证
152
152
  # task=结构层任务台账(工程做到哪一步/结果是什么)——记录单元本职:
153
153
  # 保存过程与结果;「不得自证」由 done 时的结果必填闸承接
154
+ # ref(2026-10-21 采纳外部用户 miyu 的修复二):记录单元要能 prune
155
+ # 派生索引(带 code/doc 标签的索引节点,软删进 trash 可 restore)。
156
+ # 不算放大权限:不动 can_admin、不动 delegable;判据只覆盖索引节点,
157
+ # 记忆节点带 session 标签天然不在清退范围。
154
158
  "ops_allow": ["info", "route", "read", "write", "goal", "task", "recent",
155
159
  "session", "ingest", "maintain", "insight", "ccg", "status",
156
- "edges"],
160
+ "edges", "ref"],
157
161
  "delegable": False,
158
162
  "forbidden": ["self/anchor 层", "private/secret 密级", "裁决与删除"],
159
163
  }),
package/package.json CHANGED
@@ -1,113 +1,113 @@
1
- {
2
- "name": "@furongjun1999/dsh-memory",
3
- "version": "0.9.10",
4
- "description": "灵枢(Lingshu·líng shū)DeepSeek Harness 插件:完整大脑——长期记忆/知识飞轮/自我认知/递归反思接入 DSH,对话自动沉淀进 md_cg 认知图(md 文档)",
5
- "type": "module",
6
- "main": "lib/index.js",
7
- "types": "lib/index.d.ts",
8
- "bin": {
9
- "lingshu": "./lib/cli.js",
10
- "lingshu-init": "./lib/init.js",
11
- "dsh-memory": "./lib/cli.js"
12
- },
13
- "exports": {
14
- ".": {
15
- "types": "./lib/index.d.ts",
16
- "import": "./lib/index.js"
17
- }
18
- },
19
- "files": [
20
- "lib",
21
- "src",
22
- "md_cg",
23
- "utf8_boot.py",
24
- "data/policy.json",
25
- "hive/id_charset_blocks.txt",
26
- "skills",
27
- "README.md",
28
- "dsh",
29
- "codebuddy",
30
- "zcode",
31
- "docs/规范/AI编程通用规范.md",
32
- "docs/规范/AI编程通用规范_灵枢适配.md",
33
- "docs/规范/AI编程通用规范_自检清单.md",
34
- "docs/discipline",
35
- "docs/工作纪律_认知图条目_v1.1.json",
36
- "scripts/workspace_index.py"
37
- ],
38
- "keywords": [
39
- "deepseek",
40
- "dsh",
41
- "dsh-plugin",
42
- "cordis",
43
- "memory",
44
- "agent",
45
- "aeis",
46
- "lingshu",
47
- "multi-agent",
48
- "spatiotemporal",
49
- "knowledge-graph"
50
- ],
51
- "license": "MIT",
52
- "peerDependenciesMeta": {
53
- "@deepseek-ai/cordis": {
54
- "optional": true
55
- },
56
- "@deepseek-ai/dsh-llm": {
57
- "optional": true
58
- },
59
- "@deepseek-ai/dsh-session": {
60
- "optional": true
61
- },
62
- "@deepseek-ai/dsh-system-prompt": {
63
- "optional": true
64
- },
65
- "@deepseek-ai/dsh-tools": {
66
- "optional": true
67
- }
68
- },
69
- "peerDependencies": {
70
- "@deepseek-ai/cordis": ">=4.0.1",
71
- "@deepseek-ai/dsh-llm": ">=0.1.0-rc.6",
72
- "@deepseek-ai/dsh-session": ">=0.1.0-rc.6",
73
- "@deepseek-ai/dsh-system-prompt": ">=0.1.0-rc.6",
74
- "@deepseek-ai/dsh-tools": ">=0.1.0-rc.6"
75
- },
76
- "dependencies": {
77
- "@deepseek-ai/schemastery": "^3.18.1"
78
- },
79
- "devDependencies": {
80
- "@deepseek-ai/cordis": "^4.0.1",
81
- "@deepseek-ai/dsh-llm": "^0.2.0-rc.2",
82
- "@deepseek-ai/dsh-session": "^0.2.0-rc.2",
83
- "@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.2",
84
- "@deepseek-ai/dsh-tools": "^0.2.0-rc.2",
85
- "@deepseek-ai/schemastery": "^3.0.0",
86
- "@types/node": "^26.6.5",
87
- "tsx": "^4.19.0",
88
- "typescript": "^7.0.2"
89
- },
90
- "scripts": {
91
- "build": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\" && tsc -p tsconfig.json",
92
- "test": "npm run build && node --import tsx --test \"test/*.test.ts\"",
93
- "prepare": "node -e \"const fs=require('fs');const tsc='node_modules/typescript/bin/tsc';if(fs.existsSync(tsc)){fs.rmSync('lib',{recursive:true,force:true});require('child_process').execFileSync(process.execPath,[tsc,'-p','tsconfig.json'],{stdio:'inherit'})}else if(fs.existsSync('lib/index.js')){console.log('[prepare] 跳过构建:typescript 未安装(NODE_ENV=production 或 --omit=dev 会省略 devDependencies)——需要构建请用 npm install --include=dev')}else{console.error('[prepare] 本安装会得到一个不可用的包(issue #161):包入口 main 指向 lib/index.js,但 lib/ 被 .gitignore 忽略、git 归档里没有它,此处 typescript 又未安装(NODE_ENV=production 或 --omit=dev 会省略 devDependencies)⇒ prepare 无法构建,lib/index.js 不存在。修法:用 npm install --include=dev 安装(带上 devDependencies,让 prepare 能构建),或改用已带构建产物的发布包。');process.exitCode=1}\"",
94
- "gate": "python scripts/check_unreachable.py && python scripts/check_publish_artifact.py && python scripts/check_publish_smoke.py && python scripts/cogmap_sync.py check && python scripts/link_check.py && python scripts/check_line_anchors.py && python scripts/workspace_index.py --check && python scripts/discipline_nodes.py --init --write --cg-root .tmp/discipline-cg && python scripts/verify_discipline.py --allow-missing --cg-root .tmp/discipline-cg && python scripts/gate_rust_crate_test.py && python scripts/gate_rust_parity.py && python scripts/check_local_paths.py && python scripts/body_e2e_smoke.py",
95
- "prepublishOnly": "npm run build && npm test && npm run gate"
96
- },
97
- "repository": {
98
- "type": "git",
99
- "url": "git+https://github.com/FuRongJun-1999/dsh-memory.git"
100
- },
101
- "engines": {
102
- "node": ">=22.19"
103
- },
104
- "dsh": {
105
- "bundle": {
106
- "patch": "./dsh/cordis.patch.yml"
107
- }
108
- },
109
- "publishConfig": {
110
- "access": "public",
111
- "registry": "https://registry.npmjs.org/"
112
- }
113
- }
1
+ {
2
+ "name": "@furongjun1999/dsh-memory",
3
+ "version": "0.9.12",
4
+ "description": "灵枢(Lingshu·líng shū)DeepSeek Harness 插件:完整大脑——长期记忆/知识飞轮/自我认知/递归反思接入 DSH,对话自动沉淀进 md_cg 认知图(md 文档)",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "bin": {
9
+ "lingshu": "./lib/cli.js",
10
+ "lingshu-init": "./lib/init.js",
11
+ "dsh-memory": "./lib/cli.js"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./lib/index.d.ts",
16
+ "import": "./lib/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "lib",
21
+ "src",
22
+ "md_cg",
23
+ "utf8_boot.py",
24
+ "data/policy.json",
25
+ "hive/id_charset_blocks.txt",
26
+ "skills",
27
+ "README.md",
28
+ "dsh",
29
+ "codebuddy",
30
+ "zcode",
31
+ "docs/规范/AI编程通用规范.md",
32
+ "docs/规范/AI编程通用规范_灵枢适配.md",
33
+ "docs/规范/AI编程通用规范_自检清单.md",
34
+ "docs/discipline",
35
+ "docs/工作纪律_认知图条目_v1.1.json",
36
+ "scripts/workspace_index.py"
37
+ ],
38
+ "keywords": [
39
+ "deepseek",
40
+ "dsh",
41
+ "dsh-plugin",
42
+ "cordis",
43
+ "memory",
44
+ "agent",
45
+ "aeis",
46
+ "lingshu",
47
+ "multi-agent",
48
+ "spatiotemporal",
49
+ "knowledge-graph"
50
+ ],
51
+ "license": "MIT",
52
+ "peerDependenciesMeta": {
53
+ "@deepseek-ai/cordis": {
54
+ "optional": true
55
+ },
56
+ "@deepseek-ai/dsh-llm": {
57
+ "optional": true
58
+ },
59
+ "@deepseek-ai/dsh-session": {
60
+ "optional": true
61
+ },
62
+ "@deepseek-ai/dsh-system-prompt": {
63
+ "optional": true
64
+ },
65
+ "@deepseek-ai/dsh-tools": {
66
+ "optional": true
67
+ }
68
+ },
69
+ "peerDependencies": {
70
+ "@deepseek-ai/cordis": ">=4.0.1",
71
+ "@deepseek-ai/dsh-llm": ">=0.1.0-rc.6",
72
+ "@deepseek-ai/dsh-session": ">=0.1.0-rc.6",
73
+ "@deepseek-ai/dsh-system-prompt": ">=0.1.0-rc.6",
74
+ "@deepseek-ai/dsh-tools": ">=0.1.0-rc.6"
75
+ },
76
+ "dependencies": {
77
+ "@deepseek-ai/schemastery": "^3.18.1"
78
+ },
79
+ "devDependencies": {
80
+ "@deepseek-ai/cordis": "^4.0.1",
81
+ "@deepseek-ai/dsh-llm": "^0.2.0-rc.2",
82
+ "@deepseek-ai/dsh-session": "^0.2.0-rc.2",
83
+ "@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.2",
84
+ "@deepseek-ai/dsh-tools": "^0.2.0-rc.2",
85
+ "@deepseek-ai/schemastery": "^3.0.0",
86
+ "@types/node": "^26.6.5",
87
+ "tsx": "^4.19.0",
88
+ "typescript": "^7.0.2"
89
+ },
90
+ "scripts": {
91
+ "build": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\" && tsc -p tsconfig.json",
92
+ "test": "npm run build && node --import tsx --test \"test/*.test.ts\"",
93
+ "prepare": "node -e \"const fs=require('fs');const tsc='node_modules/typescript/bin/tsc';if(fs.existsSync(tsc)){fs.rmSync('lib',{recursive:true,force:true});require('child_process').execFileSync(process.execPath,[tsc,'-p','tsconfig.json'],{stdio:'inherit'})}else if(fs.existsSync('lib/index.js')){console.log('[prepare] 跳过构建:typescript 未安装(NODE_ENV=production 或 --omit=dev 会省略 devDependencies)——需要构建请用 npm install --include=dev')}else{console.error('[prepare] 本安装会得到一个不可用的包(issue #161):包入口 main 指向 lib/index.js,但 lib/ 被 .gitignore 忽略、git 归档里没有它,此处 typescript 又未安装(NODE_ENV=production 或 --omit=dev 会省略 devDependencies)⇒ prepare 无法构建,lib/index.js 不存在。修法:用 npm install --include=dev 安装(带上 devDependencies,让 prepare 能构建),或改用已带构建产物的发布包。');process.exitCode=1}\"",
94
+ "gate": "python scripts/check_unreachable.py && python scripts/check_publish_artifact.py && python scripts/check_publish_smoke.py && python scripts/cogmap_sync.py check && python scripts/link_check.py && python scripts/check_line_anchors.py && python scripts/workspace_index.py --check && python scripts/discipline_nodes.py --init --write --cg-root .tmp/discipline-cg && python scripts/verify_discipline.py --allow-missing --cg-root .tmp/discipline-cg && python scripts/gate_rust_crate_test.py && python scripts/gate_rust_parity.py && python scripts/check_local_paths.py && python scripts/body_e2e_smoke.py",
95
+ "prepublishOnly": "npm run build && npm test && npm run gate"
96
+ },
97
+ "repository": {
98
+ "type": "git",
99
+ "url": "git+https://github.com/FuRongJun-1999/dsh-memory.git"
100
+ },
101
+ "engines": {
102
+ "node": ">=22.19"
103
+ },
104
+ "dsh": {
105
+ "bundle": {
106
+ "patch": "./dsh/cordis.patch.yml"
107
+ }
108
+ },
109
+ "publishConfig": {
110
+ "access": "public",
111
+ "registry": "https://registry.npmjs.org/"
112
+ }
113
+ }
@@ -44,6 +44,8 @@ CI_WORKFLOW = ".github/workflows/workspace-index-check.yml"
44
44
  # —— 职责真源(本脚本即真源;新增顶层目录 / 根级文件必须在此登记,否则 --check 亮红)——
45
45
  # 值 = (职责一句话, [关键入口,相对本目录;目录名亦可])
46
46
  DIR_ROLES = {
47
+ "ui": ("灵枢极简前端增量包(可选:给已装插件补可视化侧栏;不随 npm 包分发)",
48
+ ["minimal/install.ps1", "minimal/payload/web/app.js"]),
47
49
  #: 收据目录(receipt 机制):`完成` 必须带可复现命令输出(见 docs/state/会话状态.md 顶部用法)。
48
50
  #: 登记于此是按纪律 #18「新增顶层目录须在 DIR_ROLES 登记后重生成」——本条属**机械连带产物**。
49
51
  "receipts": ("收据(可复现命令输出的证据面)—— scripts/receipt.py 的 --write/--check/--list 落盘目录",