@shgroup/dsh-serenity-hooks 1.51.6 → 1.52.1

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.
@@ -24,5 +24,9 @@ export declare function verifyToolConsistency(manifestPath: string, registeredTo
24
24
  * v1.51(**D104**):新增 **`diagram`**(标签源码 → 进程内光栅化成 PNG;**缺省关**,
25
25
  * 关时连 `ctx.tools.register` 都不调用)⇒ **12**。同规格:开关关着**不影响这里列它** ——
26
26
  * 本常量描述的是"插件**具备**的工具面",不是"此刻注册了几个"。
27
+ *
28
+ * v1.52(**D121**,owner 2026-10-11 裁「引擎搬进 ACC」):新增 **`ontology`** —— 本体工程
29
+ * **引擎**(原为 CCC 的 MSM `ontology-engineering`,逐字搬迁;见 `src/ontology/engine.ts` 文件头
30
+ * 的三处改写)。它与 `praxis ontology`(**方法文本**)是**同一领域的两个面**:一个说、一个跑 ⇒ **13**。
27
31
  */
28
- export declare const REGISTERED_TOOLS: readonly ["container_fs", "container_trajectory", "dashboard", "container_git", "msm", "praxis", "handyman", "localstore", "container_admin", "im-bridge", "acc-diag", "diagram"];
32
+ export declare const REGISTERED_TOOLS: readonly ["container_fs", "container_trajectory", "dashboard", "container_git", "msm", "praxis", "handyman", "localstore", "container_admin", "im-bridge", "acc-diag", "diagram", "ontology"];
package/lib/invariant.js CHANGED
@@ -45,6 +45,10 @@ function verifyToolConsistency(manifestPath, registeredTools) {
45
45
  * v1.51(**D104**):新增 **`diagram`**(标签源码 → 进程内光栅化成 PNG;**缺省关**,
46
46
  * 关时连 `ctx.tools.register` 都不调用)⇒ **12**。同规格:开关关着**不影响这里列它** ——
47
47
  * 本常量描述的是"插件**具备**的工具面",不是"此刻注册了几个"。
48
+ *
49
+ * v1.52(**D121**,owner 2026-10-11 裁「引擎搬进 ACC」):新增 **`ontology`** —— 本体工程
50
+ * **引擎**(原为 CCC 的 MSM `ontology-engineering`,逐字搬迁;见 `src/ontology/engine.ts` 文件头
51
+ * 的三处改写)。它与 `praxis ontology`(**方法文本**)是**同一领域的两个面**:一个说、一个跑 ⇒ **13**。
48
52
  */
49
53
  const REGISTERED_TOOLS = [
50
54
  "container_fs",
@@ -58,7 +62,8 @@ const REGISTERED_TOOLS = [
58
62
  "container_admin",
59
63
  "im-bridge",
60
64
  "acc-diag",
61
- "diagram"
65
+ "diagram",
66
+ "ontology"
62
67
  ];
63
68
  //#endregion
64
69
  export { REGISTERED_TOOLS, verifyToolConsistency };
@@ -0,0 +1,168 @@
1
+ /**
2
+ * engine.ts — Ontology Definition, Validation & Semantic Review(ACC 侧引擎)
3
+ *
4
+ * 来源:宁静号 CCC 的 MSM `ontology-engineering`
5
+ * (原 `.opencode/skills/home-ontology/scripts/ontology-engineering.ts`;
6
+ * 2026-10-11 owner 裁「搬到 ACC」)。
7
+ * 搬迁方式 = **复制 + 机械改写**,不是重写 —— 判据群(M1–M10/L1–L5/D1–D8/V1–V4)与
8
+ * 全部输出文案**逐字保留**,只在"如何被调用/如何吐字"这一层做了三处改写(见下)。
9
+ *
10
+ * 本文件是**纯引擎**:只用 node 内建模块,不依赖宿主与 CCC。三段分工:
11
+ * · 引擎(本文件)= 解析与检查;
12
+ * · 工具壳 `src/tools/ontology-eng.ts` = 参数、路径守卫、把结果翻成回执;
13
+ * · 方法手册 `src/tools/ontology.ts`(praxis 第四段)= 人/模型读的方法论。
14
+ *
15
+ * 🔴 搬迁改写清单(相对原 MSM 脚本,行为差异仅此三处):
16
+ * ① **输出不再直写 `process.stdout`** ⇒ 经 `emit()`/`emitErr()` 汇聚。宿主是**长驻进程**,
17
+ * 工具调用必须**返回文本**(且不能污染服务器自己的 stdout)。
18
+ * ② **`main()` + `process.argv` 守卫 ⇒ 导出 `runOntologyCli(argv, opts)`**:**不再 `process.exit`**,
19
+ * 退出码(0/1/2/4)改为**返回值**,由工具壳翻译成可读回执。
20
+ * ③ **运行时工作目录由调用方给**(`opts.cwd` = CCC 根):引擎多处按相对路径解析
21
+ * `.opencode/skills` ⇒ 改用**显式基准目录 `BASE`**(一律 `resolve(BASE, …)`),
22
+ * **不用 `process.chdir`** —— chdir 在 **worker 线程里不被支持**
23
+ * (`ERR_WORKER_UNSUPPORTED_OPERATION`;vitest 就用 worker 跑),且长驻进程
24
+ * 改全局 cwd 是隐患。`BASE` 只在本进程内、由 `runOntologyCli` 的 try/finally
25
+ * 保存与恢复;`resolve(BASE, x)` 对**绝对路径天然无害**(原样返回)⇒ 生产路径
26
+ * (工具壳传绝对路径进来)行为不变。
27
+ *
28
+ * subcommands(与原脚本逐一对应):
29
+ * init <path> [--template minimal|full] 写一份 Turtle 模板
30
+ * check <path> [--level normal|strict] M1–M10 结构检查(strict 另出 L1–L5 提示)
31
+ * explain <path> 自然语言摘要
32
+ * verify <path> [--level operational|continuity|full] V1–V4 运行时合规
33
+ * review <path> [--level semantic|onto-clean|full] [--format prompt|json] 语义审查提示词
34
+ * compliance <path> [--skills <dir>] [--format prompt|json] 公理↔skill 合规清单
35
+ *
36
+ * 退出码:0 成功 / 1 user(参数或校验失败)/ 2 system(文件缺失/解析失败)/ 4 internal
37
+ * 错误码:PARAMETER_MISSING / PARAMETER_INVALID_VALUE / ONTO_FILE_NOT_FOUND / ONTO_PARSE_ERROR
38
+ * / ONTO_AXIOM_PARSE_ERROR / ONTO_VALIDATION_FAILED / INTERNAL_UNHANDLED_STATE
39
+ */
40
+ type Category = "user" | "system" | "operator" | "internal";
41
+ declare class MsmError extends Error {
42
+ code: string;
43
+ category: Category;
44
+ message: string;
45
+ context: Record<string, unknown>;
46
+ remediation?: string | undefined;
47
+ cause?: unknown | undefined;
48
+ constructor(code: string, category: Category, message: string, context?: Record<string, unknown>, remediation?: string | undefined, cause?: unknown | undefined);
49
+ toStderr(): string;
50
+ exitCode(): number;
51
+ }
52
+ interface PropertyDef {
53
+ type: string;
54
+ cardinality?: string;
55
+ values?: string[];
56
+ }
57
+ interface TypeDef {
58
+ description?: string;
59
+ superTypes?: string[];
60
+ rigidity?: "rigid" | "anti-rigid" | "semi-rigid";
61
+ identity?: string[];
62
+ dependsOn?: string[];
63
+ properties?: Record<string, PropertyDef>;
64
+ axioms?: string[];
65
+ }
66
+ interface RelationDef {
67
+ domain?: string;
68
+ range?: string;
69
+ cardinality?: string;
70
+ functional?: boolean;
71
+ transitive?: boolean;
72
+ symmetric?: boolean;
73
+ asymmetric?: boolean;
74
+ reflexive?: boolean;
75
+ irreflexive?: boolean;
76
+ }
77
+ interface AxiomDef {
78
+ description?: string;
79
+ rule: string;
80
+ type?: string;
81
+ }
82
+ interface OntologyDefinition {
83
+ name?: string;
84
+ version?: string;
85
+ imports?: string[];
86
+ types?: Record<string, TypeDef>;
87
+ relations?: Record<string, RelationDef>;
88
+ axioms?: AxiomDef[];
89
+ }
90
+ type ExprNode = PropAccessNode | LiteralNode | FuncCallNode | QuantifierNode | BinaryOpNode | UnaryOpNode | ImplicationNode | ParensNode;
91
+ interface PropAccessNode {
92
+ kind: "propAccess";
93
+ path: string[];
94
+ pos: number;
95
+ }
96
+ interface LiteralNode {
97
+ kind: "literal";
98
+ value: string | number | boolean | null;
99
+ raw: string;
100
+ pos: number;
101
+ }
102
+ interface FuncCallNode {
103
+ kind: "funcCall";
104
+ name: string;
105
+ args: ExprNode[];
106
+ pos: number;
107
+ }
108
+ interface QuantifierNode {
109
+ kind: "quantifier";
110
+ quant: "exists" | "forall";
111
+ variable: string;
112
+ typeName: string;
113
+ body: ExprNode;
114
+ pos: number;
115
+ }
116
+ interface BinaryOpNode {
117
+ kind: "binaryOp";
118
+ op: string;
119
+ left: ExprNode;
120
+ right: ExprNode;
121
+ pos: number;
122
+ }
123
+ interface UnaryOpNode {
124
+ kind: "unaryOp";
125
+ op: "not" | "minus";
126
+ operand: ExprNode;
127
+ pos: number;
128
+ }
129
+ interface ImplicationNode {
130
+ kind: "implication";
131
+ antecedent: ExprNode;
132
+ consequent: ExprNode;
133
+ pos: number;
134
+ }
135
+ interface ParensNode {
136
+ kind: "parens";
137
+ expr: ExprNode;
138
+ pos: number;
139
+ }
140
+ interface CheckIssue {
141
+ check: string;
142
+ severity: "error" | "warning";
143
+ message: string;
144
+ }
145
+ declare function validateOnto(onto: OntologyDefinition, level: "normal" | "strict"): CheckIssue[];
146
+ export interface OntologyRunOptions {
147
+ /** 运行时工作目录(= CCC 根):引擎多处按相对路径解析 `.opencode/skills` 等。
148
+ * ⇒ 落到**解析基准 `BASE`**(改写 ③);**不做 `process.chdir`**(worker 线程不支持)。 */
149
+ cwd?: string;
150
+ /** 顶层 skill 名(缺省 `home-serenity`):容器级资产(根标记/MSM 注册表/合规扫描)按它定位 */
151
+ topSkill?: string;
152
+ /** `sr:` 命名空间(缺省 `http://home-serenity/ontology#`) */
153
+ namespace?: string;
154
+ }
155
+ export interface OntologyRunResult {
156
+ /** 退出码:0 成功 / 1 user / 2 system / 4 internal */
157
+ code: number;
158
+ stdout: string;
159
+ stderr: string;
160
+ }
161
+ /**
162
+ * runOntologyCli —— 同步跑一次引擎调用,**返回**输出与退出码(不打印、不退出)。
163
+ *
164
+ * 调用方(工具壳 `src/tools/ontology-eng.ts`)负责:路径守卫(必须落在 CCC 内)、
165
+ * 以及把 `code !== 0` 翻成响亮的回执(引擎的 stderr 文案**逐字保留**,不重写)。
166
+ */
167
+ export declare function runOntologyCli(argv: string[], opts?: OntologyRunOptions): OntologyRunResult;
168
+ export { MsmError, validateOnto, type OntologyDefinition, type CheckIssue, type ExprNode };
@@ -0,0 +1,14 @@
1
+ export interface OntologyToolResult {
2
+ ok: boolean;
3
+ code: number;
4
+ command: string;
5
+ /** 容器内相对路径(回执里给相对路径:它是可重建的那一个) */
6
+ path: string;
7
+ stdout: string;
8
+ stderr: string;
9
+ }
10
+ /**
11
+ * 本体工程引擎(`ontology`)—— 六个子命令:init/check/explain/verify/review/compliance。
12
+ * 只读的五个不写任何文件;`init` 会在容器内**新建** .ttl 模板。
13
+ */
14
+ export declare function createOntologyTool(): import("@deepseek-ai/dsh-tools").ToolDefinition;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.51.6",
4
- "description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:12 个工具(container_fs/container_trajectory/dashboard/container_git/msm/praxis/handyman/localstore/container_admin/im-bridge/acc-diag/diagram)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 工作日志与原地重建 + 网页登录入口/微信桥/子角色/对外问答页/trajectory 唤醒注册表。适配 DSH 0.1.7-rc.1。",
3
+ "version": "1.52.1",
4
+ "description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:13 个工具(container_fs/container_trajectory/dashboard/container_git/msm/praxis/ontology/handyman/localstore/container_admin;另三个 im-bridge/acc-diag/diagram 按配置条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 工作日志与原地重建 + 网页登录入口/微信桥/子角色/对外问答页/trajectory 唤醒注册表。适配 DSH 0.1.7-rc.1。",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",