lingshu-skill 0.0.0-stage → 3.82.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.
Files changed (135) hide show
  1. package/CHANGELOG.md +2605 -0
  2. package/LICENSE +21 -0
  3. package/README.md +698 -3
  4. package/SKILL-lite.md +45 -0
  5. package/SKILL-tiny.md +37 -0
  6. package/SKILL.md +379 -0
  7. package/assets/panel.html +5616 -0
  8. package/cordis-plugin/lingshu-cron/cordis.patch.yml +3 -0
  9. package/cordis-plugin/lingshu-cron/index.js +4 -0
  10. package/cordis-plugin/lingshu-cron/package.json +34 -0
  11. package/cordis-plugin/lingshu-cron/plugin.js +1040 -0
  12. package/cordis-plugin/lingshu-guard/plugin.js +473 -0
  13. package/cordis-plugin/lingshu-im/plugin.js +635 -0
  14. package/cordis-plugin/lingshu-startup/README.md +123 -0
  15. package/cordis-plugin/lingshu-startup/cordis.patch.yml +3 -0
  16. package/cordis-plugin/lingshu-startup/index.js +4 -0
  17. package/cordis-plugin/lingshu-startup/package.json +25 -0
  18. package/cordis-plugin/lingshu-startup/plugin.js +352 -0
  19. package/cordis.patch.yml +3 -0
  20. package/docs/commands.md +243 -0
  21. package/docs/mechanics.md +610 -0
  22. package/docs/models.md +52 -0
  23. package/docs/npm-/345/217/221/345/270/203/350/257/264/346/230/216.md +49 -0
  24. package/docs/panel-api.md +198 -0
  25. package/docs/recovery.md +90 -0
  26. package/docs/tgz-/345/256/211/350/243/205/350/257/264/346/230/216.md +53 -0
  27. package/docs//350/277/233/345/261/225/344/270/216/345/276/205/345/212/236.md +804 -0
  28. package/index.js +102 -0
  29. package/package.json +52 -6
  30. package/scripts/_panel_smoke_v299.py +27 -0
  31. package/scripts/_smoke_v299.py +31 -0
  32. package/scripts/_sync_trae_cn.py +34 -0
  33. package/scripts/assembler.py +197 -0
  34. package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +53 -0
  35. package/scripts/astrbot_plugin_lingshu/PATCH_NOTES.md +28 -0
  36. package/scripts/astrbot_plugin_lingshu/README.md +58 -0
  37. package/scripts/astrbot_plugin_lingshu/_conf_schema.json +92 -0
  38. package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +2605 -0
  39. package/scripts/astrbot_plugin_lingshu/engine/README.md +698 -0
  40. package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +45 -0
  41. package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +37 -0
  42. package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +379 -0
  43. package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +5616 -0
  44. package/scripts/astrbot_plugin_lingshu/engine/docs/commands.md +243 -0
  45. package/scripts/astrbot_plugin_lingshu/engine/docs/mechanics.md +610 -0
  46. package/scripts/astrbot_plugin_lingshu/engine/docs/models.md +52 -0
  47. package/scripts/astrbot_plugin_lingshu/engine/docs/panel-api.md +198 -0
  48. package/scripts/astrbot_plugin_lingshu/engine/docs/recovery.md +90 -0
  49. package/scripts/astrbot_plugin_lingshu/engine/scripts/_panel_smoke_v299.py +27 -0
  50. package/scripts/astrbot_plugin_lingshu/engine/scripts/_smoke_v299.py +31 -0
  51. package/scripts/astrbot_plugin_lingshu/engine/scripts/_sync_trae_cn.py +34 -0
  52. package/scripts/astrbot_plugin_lingshu/engine/scripts/assembler.py +197 -0
  53. package/scripts/astrbot_plugin_lingshu/engine/scripts/behavior_baseline.py +280 -0
  54. package/scripts/astrbot_plugin_lingshu/engine/scripts/bench.py +192 -0
  55. package/scripts/astrbot_plugin_lingshu/engine/scripts/brain.py +46 -0
  56. package/scripts/astrbot_plugin_lingshu/engine/scripts/check_pressure_sync.py +55 -0
  57. package/scripts/astrbot_plugin_lingshu/engine/scripts/check_tag.py +215 -0
  58. package/scripts/astrbot_plugin_lingshu/engine/scripts/checkpoint.py +165 -0
  59. package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +4867 -0
  60. package/scripts/astrbot_plugin_lingshu/engine/scripts/context_ab.py +260 -0
  61. package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +2028 -0
  62. package/scripts/astrbot_plugin_lingshu/engine/scripts/dream.py +1137 -0
  63. package/scripts/astrbot_plugin_lingshu/engine/scripts/emotion.py +1180 -0
  64. package/scripts/astrbot_plugin_lingshu/engine/scripts/failures.py +107 -0
  65. package/scripts/astrbot_plugin_lingshu/engine/scripts/fallback_embed.py +114 -0
  66. package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +4745 -0
  67. package/scripts/astrbot_plugin_lingshu/engine/scripts/growth_parts.py +263 -0
  68. package/scripts/astrbot_plugin_lingshu/engine/scripts/insights.py +131 -0
  69. package/scripts/astrbot_plugin_lingshu/engine/scripts/make_dsh_tgz.py +92 -0
  70. package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_dialogue.py +242 -0
  71. package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_embed.py +159 -0
  72. package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_lesson.py +160 -0
  73. package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_score.py +210 -0
  74. package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_topic.py +177 -0
  75. package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +4417 -0
  76. package/scripts/astrbot_plugin_lingshu/engine/scripts/npm_prepack.py +31 -0
  77. package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_build.py +115 -0
  78. package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_cloud.py +609 -0
  79. package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +2703 -0
  80. package/scripts/astrbot_plugin_lingshu/engine/scripts/panels.py +591 -0
  81. package/scripts/astrbot_plugin_lingshu/engine/scripts/persona.py +2309 -0
  82. package/scripts/astrbot_plugin_lingshu/engine/scripts/retriever.py +195 -0
  83. package/scripts/astrbot_plugin_lingshu/engine/scripts/safety.py +368 -0
  84. package/scripts/astrbot_plugin_lingshu/engine/scripts/session_import.py +736 -0
  85. package/scripts/astrbot_plugin_lingshu/engine/scripts/session_rag.py +228 -0
  86. package/scripts/astrbot_plugin_lingshu/engine/scripts/session_summary.py +123 -0
  87. package/scripts/astrbot_plugin_lingshu/engine/scripts/summarizer.py +252 -0
  88. package/scripts/astrbot_plugin_lingshu/main.py +703 -0
  89. package/scripts/astrbot_plugin_lingshu/make_checksums.py +87 -0
  90. package/scripts/astrbot_plugin_lingshu/metadata.yaml +7 -0
  91. package/scripts/behavior_baseline.py +280 -0
  92. package/scripts/bench.py +192 -0
  93. package/scripts/brain.py +46 -0
  94. package/scripts/check_pressure_sync.py +55 -0
  95. package/scripts/check_tag.py +215 -0
  96. package/scripts/check_version.py +265 -0
  97. package/scripts/checkpoint.py +165 -0
  98. package/scripts/cli.py +4867 -0
  99. package/scripts/context_ab.py +260 -0
  100. package/scripts/core.py +2028 -0
  101. package/scripts/dream.py +1137 -0
  102. package/scripts/emotion.py +1180 -0
  103. package/scripts/failures.py +107 -0
  104. package/scripts/fallback_embed.py +114 -0
  105. package/scripts/growth.py +4745 -0
  106. package/scripts/growth_parts.py +263 -0
  107. package/scripts/hooks/pre-commit +18 -0
  108. package/scripts/hooks/pre-push +20 -0
  109. package/scripts/insights.py +131 -0
  110. package/scripts/make_dsh_tgz.py +92 -0
  111. package/scripts/make_manifest.py +254 -0
  112. package/scripts/make_plugin_zip.py +88 -0
  113. package/scripts/mem_dialogue.py +242 -0
  114. package/scripts/mem_embed.py +159 -0
  115. package/scripts/mem_lesson.py +160 -0
  116. package/scripts/mem_score.py +210 -0
  117. package/scripts/mem_topic.py +177 -0
  118. package/scripts/memory.py +4417 -0
  119. package/scripts/npm_prepack.py +31 -0
  120. package/scripts/panel_build.py +115 -0
  121. package/scripts/panel_cloud.py +609 -0
  122. package/scripts/panel_server.py +2703 -0
  123. package/scripts/panels.py +591 -0
  124. package/scripts/persona.py +2309 -0
  125. package/scripts/recreate_push.ps1 +117 -0
  126. package/scripts/retriever.py +195 -0
  127. package/scripts/run_tests.py +91 -0
  128. package/scripts/safety.py +368 -0
  129. package/scripts/session_import.py +736 -0
  130. package/scripts/session_rag.py +228 -0
  131. package/scripts/session_summary.py +123 -0
  132. package/scripts/summarizer.py +252 -0
  133. package/scripts/sync_engine.py +139 -0
  134. package/scripts/update_dsh_copy.ps1 +107 -0
  135. package/start-panel.bat +60 -0
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """npm publish 前的准备:生成 engine 副本 + 清掉 pycache,保证包里没有垃圾。
4
+
5
+ npm 的 files 白名单里的目录无法被 .npmignore 排除,所以 pycache 必须在
6
+ 打包前从磁盘上清掉,而不是靠 ignore 规则。
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import shutil
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ ROOT = Path(__file__).resolve().parent.parent
15
+ sys.path.insert(0, str(ROOT / "scripts"))
16
+
17
+ import sync_engine # noqa: E402
18
+
19
+ if sync_engine.sync() != 0:
20
+ raise SystemExit("[prepack] engine 副本同步失败,拒绝发布空壳包")
21
+
22
+ removed = 0
23
+ for d in ROOT.rglob("__pycache__"):
24
+ # 只清仓库内的(数据目录不在仓库下,不受影响)
25
+ if d.is_dir():
26
+ shutil.rmtree(d, ignore_errors=True)
27
+ removed += 1
28
+ for p in ROOT.rglob("*.pyc"):
29
+ p.unlink(missing_ok=True)
30
+ removed += 1
31
+ print(f"[prepack] engine 已同步,清理 {removed} 个 pyc 缓存")
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """面板构建:把 panel_src/ 拼成 assets/panel.html(无依赖、字节级可复现)。
4
+
5
+ 为什么不直接手改 271KB 单文件:4900 行里 4 段 script / 3 段 style,改一处要全文搜,
6
+ review 也没法看。拆成源码后:
7
+ panel_src/index.html 外壳(样式/脚本位置留 <!--@@BLOCK:n@@--> 占位)
8
+ panel_src/styles/*.css 样式块(按出现顺序)
9
+ panel_src/js/*.js 脚本块(按出现顺序)
10
+ panel_src/blocks.json 每个占位的标签属性 + 文件名(保证重建字节一致)
11
+
12
+ 用法:
13
+ python scripts/panel_build.py --split # 一次性:把现有 assets/panel.html 拆成源码
14
+ python scripts/panel_build.py # 从源码重建
15
+ python scripts/panel_build.py --check # 只比对:源码重建结果 == 现成文件
16
+ """
17
+ from __future__ import annotations
18
+
19
+ import json
20
+ import re
21
+ import sys
22
+ from pathlib import Path
23
+
24
+ ROOT = Path(__file__).resolve().parent.parent
25
+ SRC = ROOT / "panel_src"
26
+ OUT = ROOT / "assets" / "panel.html"
27
+
28
+ BLOCK_RE = re.compile(rb"(<(style|script)\b[^>]*>)(.*?)(</\2>)", re.S)
29
+ NAMES = {
30
+ "style": ["base.css", "views.css", "enhance.css"],
31
+ "script": ["app.js", "core.js", "panels.js", "enhance.js"],
32
+ }
33
+
34
+
35
+ def split(out: Path = OUT, src: Path = SRC) -> int:
36
+ raw = out.read_bytes()
37
+ blocks = list(BLOCK_RE.finditer(raw))
38
+ if not blocks:
39
+ print("[panel] 没找到 <style>/<script> 块", file=sys.stderr)
40
+ return 1
41
+ src.mkdir(parents=True, exist_ok=True)
42
+ (src / "styles").mkdir(exist_ok=True)
43
+ (src / "js").mkdir(exist_ok=True)
44
+ meta = []
45
+ pos = 0
46
+ shell = []
47
+ counters = {"style": 0, "script": 0}
48
+ for m in blocks:
49
+ shell.append(raw[pos:m.start()])
50
+ kind = m.group(2).decode()
51
+ idx = counters[kind]
52
+ counters[kind] += 1
53
+ names = NAMES[kind]
54
+ name = names[idx] if idx < len(names) else f"{kind}{idx}.{'css' if kind == 'style' else 'js'}"
55
+ sub = "styles" if kind == "style" else "js"
56
+ (src / sub / name).write_bytes(m.group(3))
57
+ token = f"<!--@@BLOCK:{len(meta)}@@-->".encode()
58
+ shell.append(token)
59
+ meta.append({"kind": kind, "open": m.group(1).decode(), "file": f"{sub}/{name}"})
60
+ pos = m.end()
61
+ shell.append(raw[pos:])
62
+ (src / "index.html").write_bytes(b"".join(shell))
63
+ (src / "blocks.json").write_text(
64
+ json.dumps(meta, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
65
+ print(f"[panel] 拆出 {len(meta)} 块 → panel_src/({counters['style']} 样式 / {counters['script']} 脚本)")
66
+ return 0
67
+
68
+
69
+ def _norm_bytes(data: bytes) -> bytes:
70
+ """比较用规范形态:去 BOM + CRLF→LF。
71
+
72
+ 和 manifest / sync_engine / make_checksums 保持同一口径。否则在 Windows 上
73
+ 只要 git 按 core.autocrlf 把源码写成 CRLF、产物是 LF,`--check` 就会假红
74
+ (实测踩过:git checkout 之后一次次报"不同步",其实内容一模一样)。
75
+ """
76
+ if data.startswith(b"\xef\xbb\xbf"):
77
+ data = data[3:]
78
+ return data.replace(b"\r\n", b"\n")
79
+
80
+
81
+ def build(src: Path = SRC, out: Path | None = OUT) -> bytes:
82
+ """拼装产物;out=None 时只返回字节、不落盘(--check 用,检查不该改文件)。"""
83
+ shell = (src / "index.html").read_bytes()
84
+ meta = json.loads((src / "blocks.json").read_text(encoding="utf-8"))
85
+ for i, blk in enumerate(meta):
86
+ token = f"<!--@@BLOCK:{i}@@-->".encode()
87
+ body = (src / blk["file"]).read_bytes()
88
+ close = b"</style>" if blk["kind"] == "style" else b"</script>"
89
+ shell = shell.replace(token, blk["open"].encode() + body + close, 1)
90
+ if out is not None:
91
+ out.parent.mkdir(parents=True, exist_ok=True)
92
+ out.write_bytes(shell)
93
+ return shell
94
+
95
+
96
+ def main(argv=None) -> int:
97
+ argv = argv if argv is not None else sys.argv[1:]
98
+ if "--split" in argv:
99
+ return split()
100
+ if "--check" in argv:
101
+ old = OUT.read_bytes() if OUT.exists() else b""
102
+ new = build(out=None) # 只读:检查不能顺手把产物重写掉
103
+ if _norm_bytes(old) != _norm_bytes(new):
104
+ print("[panel] 不同步:assets/panel.html != panel_src 重建结果"
105
+ "(改了源码就跑 python scripts/panel_build.py)", file=sys.stderr)
106
+ return 1
107
+ print(f"[panel] OK:{len(new)} 字节,源码与产物一致")
108
+ return 0
109
+ data = build()
110
+ print(f"[panel] 已生成 assets/panel.html:{len(data)} 字节")
111
+ return 0
112
+
113
+
114
+ if __name__ == "__main__":
115
+ sys.exit(main())