@shgroup/dsh-serenity-hooks 1.16.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.
@@ -0,0 +1,48 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import "node:path";
3
+ //#region src/invariant.ts
4
+ /**
5
+ * invariant.ts — 包级不变量伴生(dsh-my-rsi creating-a-plugin 规范)
6
+ *
7
+ * 检查:dsh.plugin.json 的 contributes.tools 与代码实际注册的工具一致。
8
+ * 挂载时 plugin-local 会校验清单;本不变量让仓库内 `verify-package-invariants`
9
+ * 类门禁也可直接调用。
10
+ */
11
+ /** 读取插件清单;缺失/非法返回 null */
12
+ function readPluginManifest(manifestPath) {
13
+ if (!existsSync(manifestPath)) return null;
14
+ try {
15
+ return JSON.parse(readFileSync(manifestPath, "utf-8"));
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+ /**
21
+ * 校验清单声明的工具与代码注册的工具一致。
22
+ * 返回不一致项列表(空 = 通过)。
23
+ */
24
+ function verifyToolConsistency(manifestPath, registeredTools) {
25
+ const manifest = readPluginManifest(manifestPath);
26
+ if (!manifest) return [`manifest not found or invalid: ${manifestPath}`];
27
+ const declared = manifest.contributes?.tools ?? [];
28
+ const missing = declared.filter((t) => !registeredTools.includes(t));
29
+ const undeclared = registeredTools.filter((t) => !declared.includes(t));
30
+ const issues = [];
31
+ if (missing.length) issues.push(`manifest declares tools not registered: ${missing.join(", ")}`);
32
+ if (undeclared.length) issues.push(`registered tools not declared in manifest: ${undeclared.join(", ")}`);
33
+ return issues;
34
+ }
35
+ /** 包级不变量:本插件注册的工具集合(与 dsh.plugin.json contributes.tools 一致) */
36
+ const REGISTERED_TOOLS = [
37
+ "cc_fs",
38
+ "session",
39
+ "acc_kit",
40
+ "cc_git",
41
+ "acc_msm",
42
+ "eap",
43
+ "neat",
44
+ "cce",
45
+ "loop"
46
+ ];
47
+ //#endregion
48
+ export { REGISTERED_TOOLS, readPluginManifest, verifyToolConsistency };
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@shgroup/dsh-serenity-hooks",
3
+ "version": "1.16.0",
4
+ "description": "宁静号 ACC harness — Native Cordis 插件(DeepSeek Harness 运行时)。真实 DSH 工具注册(cc_fs/session/acc_msm 等 9 工具)+ 拦截缝机械约束(safe-mode/路径守卫/会话落盘)+ 系统提示词注入(ACC/CCE/Constraints/SKILL/Session 五块)。适配 DSH 公开版(deepseek-ai/deepseek-harness 0.1.0-rc)。",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/tellmewhattodo/dsh-serenity-plugin.git"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "type": "module",
14
+ "main": "./lib/index.js",
15
+ "types": "./lib/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/index.d.ts",
19
+ "import": "./lib/index.js"
20
+ },
21
+ "./client": "./lib/client.js",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "lib/index.js",
26
+ "lib/client.js",
27
+ "lib/invariant.js",
28
+ "lib/types/**/*.d.ts",
29
+ "cordis.patch.yml",
30
+ "dsh.plugin.json"
31
+ ],
32
+ "scripts": {
33
+ "typecheck": "tsc --noEmit",
34
+ "test": "vitest run",
35
+ "build": "tsc -p tsconfig.json && tsdown -c tsdown.config.ts",
36
+ "prepare": "tsdown --config tsdown.prepare.config.ts"
37
+ },
38
+ "dsh": {
39
+ "bundle": {
40
+ "patch": "./cordis.patch.yml"
41
+ },
42
+ "client": {
43
+ "inject": [
44
+ "@deepseek-ai/dsh-client-runtime"
45
+ ],
46
+ "platform": "web"
47
+ }
48
+ },
49
+ "peerDependencies": {
50
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.5",
51
+ "@deepseek-ai/dsh-agent-loop": "^0.1.0-rc.5",
52
+ "@deepseek-ai/dsh-compaction": "^0.1.0-rc.5",
53
+ "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.5",
54
+ "@deepseek-ai/dsh-llm": "^0.1.0-rc.5",
55
+ "@deepseek-ai/dsh-session": "^0.1.0-rc.5",
56
+ "@deepseek-ai/dsh-shell": "^0.1.0-rc.5",
57
+ "@deepseek-ai/dsh-shell-env": "^0.1.0-rc.5",
58
+ "@deepseek-ai/dsh-skill": "^0.1.0-rc.5",
59
+ "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.5",
60
+ "@deepseek-ai/dsh-tools": "^0.1.0-rc.5",
61
+ "@deepseek-ai/schemastery": "^0.1.0-rc.5",
62
+ "cordis": "^4.0.0-rc.7"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "@deepseek-ai/dsh-host-webserver": {
66
+ "optional": true
67
+ },
68
+ "@deepseek-ai/dsh-shell-env": {
69
+ "optional": true
70
+ },
71
+ "@deepseek-ai/dsh-skill": {
72
+ "optional": true
73
+ },
74
+ "@deepseek-ai/dsh-agent-loop": {
75
+ "optional": true
76
+ },
77
+ "@deepseek-ai/dsh-compaction": {
78
+ "optional": true
79
+ }
80
+ },
81
+ "devDependencies": {
82
+ "@types/node": "^20.0.0",
83
+ "@types/react": "^18.2.0",
84
+ "react": "^18.2.0",
85
+ "tsdown": "^0.22.14",
86
+ "typescript": "^5.4.0",
87
+ "unrun": "^0.3.1",
88
+ "vitest": "^1.6.0"
89
+ }
90
+ }