lingshu-skill 3.97.0 → 3.98.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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # 更新日志
2
2
 
3
+ ## v3.98(2026-11-23)
4
+
5
+ > 主题:**设置页上线后的自审修复**——三处真缺陷,其中一处是安全问题。
6
+
7
+ - **① 只读模式仍能改配置(安全)**:`config_set` / `config_unset` 没有 `READONLY` 检查。面板 HTTP 层虽有只读门控,但函数层没守——CLI `config set`、脚本、设置页三条路径都能绕过;实测 `READONLY=True` 下写盘成功。
8
+ - 修:两个函数各加 `if READONLY: raise PermissionError(...)`。
9
+ - **② `panel_port` 是假开关**:`panel_server.py --port` 的 default 硬编码 `8765`,从不读 config——设置页改端口完全无效。
10
+ - 修:`--port` 缺省时读 `config.json` 的 `panel_port`(带 1~65535 校验,坏值退回 8765)。实测设 18799 后服务确实监听 18799。
11
+ - **③ `extensions_enabled` 不在 `DEFAULT_CONFIG`**:只有读取方 `.get(key, False)` 兜底,设置页拿不到默认值。
12
+ - 修:补进 `DEFAULT_CONFIG`(默认 False)。
13
+
14
+ 验证:设置页边界审计 6 项全过(布尔 8 种写法 / 浮点边界 / 整型拒小数 / 枚举大小写 / 父段缺失时建嵌套 / unset 不误删同级键);只读拦截三函数实测;端口跟随 config 实测;全量测试 63/63。
15
+
3
16
  ## v3.97(2026-11-23)
4
17
 
5
18
  > 主题:**面板可用性**——把开关和数值搬到面板上,左侧栏按用途分组。
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
4
4
 
5
- > 当前版本 **v3.97**(变更见 [CHANGELOG.md](CHANGELOG.md))
5
+ > 当前版本 **v3.98**(变更见 [CHANGELOG.md](CHANGELOG.md))
6
6
 
7
7
  > 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
8
8
 
package/SKILL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lingshu
3
3
  title: 灵枢
4
- version: 3.97
4
+ version: 3.98
5
5
  description: 类脑持久记忆、人格与成长系统——跨会话记住事情、长出自己的人格、上下文将满时做梦式整理记忆。用户提到记忆/记住/上次/人格/设定/性格/知识库/笔记/日志/成长/自我进化/工作记忆,或新会话开始需要恢复关系与上下文时使用。纯本地零依赖。
6
6
  ---
7
7
 
@@ -397,6 +397,11 @@ startup 注入的记忆块与 cron 的瞬态提醒**同名**,于是 cron 的 p
397
397
  - **顺带修**:`core.config_set/unset` 原来只做 `cfg[key]=val`,`config set embed.timeout_sec 30` 会写成字面键、读取方永远看不到——现在支持**点号路径**(面板与 CLI 同时受益)。
398
398
  - 实测:GET 22 项 5 组;POST 扁平/嵌套键均 200 并落盘;非法值(review_threshold=9 / panel_port=1 / 非白名单键)全部 400;首页含设置视图与分组导航;无头 Edge 截图 3 张(概览/设置/窄屏)人工核对。
399
399
 
400
+ 68. **【已修 v3.98】设置页三项缺陷**(v3.97 上线后自审发现):
401
+ - **① 只读模式能改配置(安全)**:`panel_settings.set_value` 直接调 `core.config_set`,而 `config_set`/`config_unset` **没有 READONLY 检查**——面板 HTTP 层虽有门控,但函数层没守(CLI `config set` 同样能绕过)。实测 `READONLY=True` 下仍写盘成功。**修**:两个函数各加 `if READONLY: raise PermissionError`,面板/CLI/脚本三条路径一起守住。
402
+ - **② `panel_port` 是假开关**:`panel_server.py --port` 的 default 硬编码 `8765`,**不读 config**,设置页改端口完全无效。**修**:`--port` 缺省时读 `config.json` 的 `panel_port`(含 1~65535 校验),实测设 18799 后服务确实起在 18799。
403
+ - **③ `extensions_enabled` 不在 DEFAULT_CONFIG**:只有读取方 `.get(key, False)` 兜底,设置页拿不到默认值(显示 undefined)、`unset` 后 UI 语义也不明确。**修**:补进 `DEFAULT_CONFIG`(默认 False)。
404
+
400
405
  ## 三、已知问题与风险
401
406
 
402
407
  | # | 现象 | 影响 | 处置 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lingshu-skill",
3
- "version": "3.97.0",
3
+ "version": "3.98.0",
4
4
  "description": "Brain-inspired persistent memory, persona and growth system for AI coding agents. Local-only, zero-dependency Python. Requires Python 3.10+.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "PATCH_NOTES.md": "9296e524f743f358fd11115598398a754cfd69534526dde9c8ad85f14a418f89",
3
3
  "README.md": "3d634d743b085eebd2cbb5dd3a00edfa728ed23947e20cc29e7c3b29087ec043",
4
- "engine/CHANGELOG.md": "b654039860bc7762b10c9d495d3a27e3cf43808a6814e28825c6181aeca4dde7",
5
- "engine/README.md": "d131387f099c9f14db7ad6986a19a2378b2130f55350542042462003d3082e1f",
4
+ "engine/CHANGELOG.md": "7499154374ae16aa7e73ab0873262fa106d83443c2f4cc33cf2730a3bbfc8bf5",
5
+ "engine/README.md": "d5b961195b6e0606c29a8b4f670f266409a8c419b060a99b941fde09dd4ae64d",
6
6
  "engine/SKILL-lite.md": "04b87789232a0f7537c861c857888b4a0e947bcf92a461cbad5328af05361c58",
7
7
  "engine/SKILL-tiny.md": "74e1955cc5bf4ec0ca28d52030f799f039283de27a52345a33ce783d6ee0c608",
8
- "engine/SKILL.md": "65752502a4cd25926d9ce7cab54a17be072a528b7821591d0ec1381e034f16fc",
8
+ "engine/SKILL.md": "d8456c9affa145f121c00c589da2b03ac8a2a8faf959e425b1b7d5e9c5c2c3b4",
9
9
  "engine/assets/panel.html": "9607405a563a82efe6497365a52a8c391a1ebc64143b14d844d01657b99d6a50",
10
10
  "engine/docs/commands.md": "63f43d24e64d6eab5b1f901756dff15f53b12a0c1a05fc029bfe82c9b01191e5",
11
11
  "engine/docs/mechanics.md": "e8a6602a434ed5b78cac64a98884f65a6888eb48daa7a1c0be1f6c3984041b34",
@@ -21,7 +21,7 @@
21
21
  "engine/scripts/checkpoint.py": "ec74e70e6ae1338ee3d7048c71b8297a1f60bd3c572a2e2843b8e9696bdf2d9a",
22
22
  "engine/scripts/cli.py": "ff8f8ae6a2b36cb0134d16f8c4565d00b2b8826b481a06d76f8537f6ef3140c1",
23
23
  "engine/scripts/context_ab.py": "3d383f1fc16d328612825bbf731866fa427da0746490d027a0ddb719d210f1cb",
24
- "engine/scripts/core.py": "eefd4b2af4c854e867e2b1f42df49983cec1f21c29143ca6e69b5373bf266cb5",
24
+ "engine/scripts/core.py": "c2ffdf91f406919e693f424ff31e591ed460dc78facf13aaeebfb66fe136b949",
25
25
  "engine/scripts/dream.py": "c1ba3de2958fb045db7b6962a6dd0fcf70f225bfb4d372dd9c3e8584e4f759ce",
26
26
  "engine/scripts/emotion.py": "c2928217a856c9201291ebd63dee33a4a641ff30dcd79964738c24e7a9d94672",
27
27
  "engine/scripts/failures.py": "3a16234a1871f62e3ba7b7b743110b4044fb7b715b4d0e924b8ebf1cf0be50d0",
@@ -39,7 +39,7 @@
39
39
  "engine/scripts/npm_prepack.py": "d62c491a6f9edfcab2dd465a995e72df879a61b4da26ae0fe76121c8adc77e02",
40
40
  "engine/scripts/panel_build.py": "6394c1d74d203093e43b2106d7acca6e0ca9db61ca1cd6cd3a1616053653414b",
41
41
  "engine/scripts/panel_cloud.py": "fff72888123d45bbf05ab329a06b2126f1c0b972c76283ecff32454bc4155c58",
42
- "engine/scripts/panel_server.py": "c6341348ab505f053c87325bcbcbea8d99998219c71ce9867387dd3706cf6ee0",
42
+ "engine/scripts/panel_server.py": "396c3e567f267b1b9f63c7a2a78d3708e71562b2531a5570334d2d04a265d017",
43
43
  "engine/scripts/panel_settings.py": "327514abf90223dda039150839e6c33808652157c3de111eb8323ea7111dac04",
44
44
  "engine/scripts/panels.py": "87dfce47693340af7c9bc6010a593256331e32c2e8504a0ac0745cf2ef992fd6",
45
45
  "engine/scripts/persona.py": "fb748d2fb7b176d9dd0d7394de69ba4560da7f4205f62256477d3a69dcbdf0f5",
@@ -1,5 +1,18 @@
1
1
  # 更新日志
2
2
 
3
+ ## v3.98(2026-11-23)
4
+
5
+ > 主题:**设置页上线后的自审修复**——三处真缺陷,其中一处是安全问题。
6
+
7
+ - **① 只读模式仍能改配置(安全)**:`config_set` / `config_unset` 没有 `READONLY` 检查。面板 HTTP 层虽有只读门控,但函数层没守——CLI `config set`、脚本、设置页三条路径都能绕过;实测 `READONLY=True` 下写盘成功。
8
+ - 修:两个函数各加 `if READONLY: raise PermissionError(...)`。
9
+ - **② `panel_port` 是假开关**:`panel_server.py --port` 的 default 硬编码 `8765`,从不读 config——设置页改端口完全无效。
10
+ - 修:`--port` 缺省时读 `config.json` 的 `panel_port`(带 1~65535 校验,坏值退回 8765)。实测设 18799 后服务确实监听 18799。
11
+ - **③ `extensions_enabled` 不在 `DEFAULT_CONFIG`**:只有读取方 `.get(key, False)` 兜底,设置页拿不到默认值。
12
+ - 修:补进 `DEFAULT_CONFIG`(默认 False)。
13
+
14
+ 验证:设置页边界审计 6 项全过(布尔 8 种写法 / 浮点边界 / 整型拒小数 / 枚举大小写 / 父段缺失时建嵌套 / unset 不误删同级键);只读拦截三函数实测;端口跟随 config 实测;全量测试 63/63。
15
+
3
16
  ## v3.97(2026-11-23)
4
17
 
5
18
  > 主题:**面板可用性**——把开关和数值搬到面板上,左侧栏按用途分组。
@@ -2,7 +2,7 @@
2
2
 
3
3
  > 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
4
4
 
5
- > 当前版本 **v3.97**(变更见 [CHANGELOG.md](CHANGELOG.md))
5
+ > 当前版本 **v3.98**(变更见 [CHANGELOG.md](CHANGELOG.md))
6
6
 
7
7
  > 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
8
8
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: lingshu
3
3
  title: 灵枢
4
- version: 3.97
4
+ version: 3.98
5
5
  description: 类脑持久记忆、人格与成长系统——跨会话记住事情、长出自己的人格、上下文将满时做梦式整理记忆。用户提到记忆/记住/上次/人格/设定/性格/知识库/笔记/日志/成长/自我进化/工作记忆,或新会话开始需要恢复关系与上下文时使用。纯本地零依赖。
6
6
  ---
7
7
 
@@ -312,6 +312,10 @@ DEFAULT_CONFIG = {
312
312
  # 开启后,库文件 mtime 未变 + TTL 内的重复 startup 直接复用上次注入文本,
313
313
  # 跳过整库遍历与 recall 重算(跨天恢复首轮明显更快)。
314
314
  # 记忆/人格文件与非易失配置哈希都会入缓存键;TTL 只作最后兜底。
315
+ # 扩展模块默认关(扩展是任意本地代码,等于完全信任本机)。
316
+ # 补进 DEFAULT_CONFIG:原来只有读取方 .get(key, False) 兜底,config 里没有这个键,
317
+ # 面板设置页会显示成"未设置"、默认值也拿不到(P10 #68)。
318
+ "extensions_enabled": False,
315
319
  "session_state_cache": False,
316
320
  "session_state_ttl": 300,
317
321
  # 候选7 跨对话上下文摄取:把别的会话/宿主导出的对话(.jsonl/.md/.txt)
@@ -795,6 +799,10 @@ def config_set(key: str, value: str) -> dict:
795
799
  raise ValueError(f"panel_port 需要在 1~65535 之间,收到:{value!r}")
796
800
  val = num
797
801
  ensure_home()
802
+ # 只读降级(含用户显式 --ro)下不允许改配置:面板设置页 / CLI config set
803
+ # 都走这里,函数层必须自己守一道(HTTP 层有门控,但 CLI 与脚本没有)。
804
+ if READONLY:
805
+ raise PermissionError("记忆库当前只读,无法修改配置。用 --home 指向可写目录。")
798
806
  with _locked(HOME / "config.json"):
799
807
  cfg = load_config()
800
808
  _set_cfg_path(cfg, key, val)
@@ -804,6 +812,8 @@ def config_set(key: str, value: str) -> dict:
804
812
 
805
813
  def config_unset(key: str) -> dict:
806
814
  ensure_home()
815
+ if READONLY:
816
+ raise PermissionError("记忆库当前只读,无法修改配置。用 --home 指向可写目录。")
807
817
  with _locked(HOME / "config.json"):
808
818
  cfg = load_config()
809
819
  _unset_cfg_path(cfg, key)
@@ -2722,10 +2722,21 @@ def serve(port: int = 8765, open_browser: bool = True) -> None:
2722
2722
  if __name__ == "__main__":
2723
2723
  import argparse
2724
2724
  ap = argparse.ArgumentParser()
2725
- ap.add_argument("--port", type=int, default=8765)
2725
+ # 端口优先取 config.json 的 panel_port(设置页可改),再退回 8765。
2726
+ # 原来 default 硬编码 8765,设置页改 panel_port 完全无效——是个假开关。
2727
+ ap.add_argument("--port", type=int, default=None,
2728
+ help="监听端口;缺省读 config.json 的 panel_port,再退回 8765")
2726
2729
  ap.add_argument("--no-browser", action="store_true")
2727
2730
  ap.add_argument("--home", help="测试用:指定数据目录(透传给 brain,不影响正式数据)")
2728
2731
  a = ap.parse_args()
2729
2732
  if a.home:
2730
2733
  brain._override_home(["--home", a.home])
2731
- serve(a.port, not a.no_browser)
2734
+ port = a.port
2735
+ if port is None:
2736
+ try:
2737
+ port = int(brain.load_config().get("panel_port") or 8765)
2738
+ except Exception:
2739
+ port = 8765
2740
+ if not (1 <= port <= 65535):
2741
+ port = 8765
2742
+ serve(port, not a.no_browser)
package/scripts/core.py CHANGED
@@ -312,6 +312,10 @@ DEFAULT_CONFIG = {
312
312
  # 开启后,库文件 mtime 未变 + TTL 内的重复 startup 直接复用上次注入文本,
313
313
  # 跳过整库遍历与 recall 重算(跨天恢复首轮明显更快)。
314
314
  # 记忆/人格文件与非易失配置哈希都会入缓存键;TTL 只作最后兜底。
315
+ # 扩展模块默认关(扩展是任意本地代码,等于完全信任本机)。
316
+ # 补进 DEFAULT_CONFIG:原来只有读取方 .get(key, False) 兜底,config 里没有这个键,
317
+ # 面板设置页会显示成"未设置"、默认值也拿不到(P10 #68)。
318
+ "extensions_enabled": False,
315
319
  "session_state_cache": False,
316
320
  "session_state_ttl": 300,
317
321
  # 候选7 跨对话上下文摄取:把别的会话/宿主导出的对话(.jsonl/.md/.txt)
@@ -795,6 +799,10 @@ def config_set(key: str, value: str) -> dict:
795
799
  raise ValueError(f"panel_port 需要在 1~65535 之间,收到:{value!r}")
796
800
  val = num
797
801
  ensure_home()
802
+ # 只读降级(含用户显式 --ro)下不允许改配置:面板设置页 / CLI config set
803
+ # 都走这里,函数层必须自己守一道(HTTP 层有门控,但 CLI 与脚本没有)。
804
+ if READONLY:
805
+ raise PermissionError("记忆库当前只读,无法修改配置。用 --home 指向可写目录。")
798
806
  with _locked(HOME / "config.json"):
799
807
  cfg = load_config()
800
808
  _set_cfg_path(cfg, key, val)
@@ -804,6 +812,8 @@ def config_set(key: str, value: str) -> dict:
804
812
 
805
813
  def config_unset(key: str) -> dict:
806
814
  ensure_home()
815
+ if READONLY:
816
+ raise PermissionError("记忆库当前只读,无法修改配置。用 --home 指向可写目录。")
807
817
  with _locked(HOME / "config.json"):
808
818
  cfg = load_config()
809
819
  _unset_cfg_path(cfg, key)
@@ -2722,10 +2722,21 @@ def serve(port: int = 8765, open_browser: bool = True) -> None:
2722
2722
  if __name__ == "__main__":
2723
2723
  import argparse
2724
2724
  ap = argparse.ArgumentParser()
2725
- ap.add_argument("--port", type=int, default=8765)
2725
+ # 端口优先取 config.json 的 panel_port(设置页可改),再退回 8765。
2726
+ # 原来 default 硬编码 8765,设置页改 panel_port 完全无效——是个假开关。
2727
+ ap.add_argument("--port", type=int, default=None,
2728
+ help="监听端口;缺省读 config.json 的 panel_port,再退回 8765")
2726
2729
  ap.add_argument("--no-browser", action="store_true")
2727
2730
  ap.add_argument("--home", help="测试用:指定数据目录(透传给 brain,不影响正式数据)")
2728
2731
  a = ap.parse_args()
2729
2732
  if a.home:
2730
2733
  brain._override_home(["--home", a.home])
2731
- serve(a.port, not a.no_browser)
2734
+ port = a.port
2735
+ if port is None:
2736
+ try:
2737
+ port = int(brain.load_config().get("panel_port") or 8765)
2738
+ except Exception:
2739
+ port = 8765
2740
+ if not (1 <= port <= 65535):
2741
+ port = 8765
2742
+ serve(port, not a.no_browser)