@shgroup/dsh-serenity-hooks 1.137.11 → 1.137.13

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/lib/invariant.js CHANGED
@@ -83,7 +83,7 @@ function assertManifestProse(manifestPath, readmePaths) {
83
83
  if (absent.length) issues.push(`${s.where} 的名单缺 ${absent.length} 项:${absent.join(", ")}(防"数对了、名单漏了")`);
84
84
  }
85
85
  const countCn = cnNumberOf(n);
86
- const condCn = cnNumberOf(3);
86
+ const condCn = cnNumberOf(2);
87
87
  for (const p of readmePaths) {
88
88
  if (!existsSync(p)) {
89
89
  issues.push(`README 不存在:${p}`);
@@ -95,7 +95,7 @@ function assertManifestProse(manifestPath, readmePaths) {
95
95
  continue;
96
96
  }
97
97
  if (m[1] !== countCn) issues.push(`${p} 的 §3.1 标题写「${m[1]}个工具」,应为「${countCn}个工具」(工具数已 ${n})`);
98
- if (m[2] !== void 0 && m[2] !== condCn) issues.push(`${p} 的 §3.1 标题写「其中${m[2]}个按条件出现」,应为「其中${condCn}个按条件出现」(条件工具数已 3)`);
98
+ if (m[2] !== void 0 && m[2] !== condCn) issues.push(`${p} 的 §3.1 标题写「其中${m[2]}个按条件出现」,应为「其中${condCn}个按条件出现」(条件工具数已 2)`);
99
99
  }
100
100
  return issues;
101
101
  }
@@ -112,7 +112,7 @@ function cnNumberOf(n) {
112
112
  const cn = [
113
113
  "零",
114
114
  "一",
115
- "二",
115
+ "两",
116
116
  "三",
117
117
  "四",
118
118
  "五",
@@ -164,10 +164,9 @@ const REGISTERED_TOOLS = [
164
164
  "container_admin",
165
165
  "browser_slot",
166
166
  "im-bridge",
167
- "diagram",
168
- "reconstruct"
167
+ "diagram"
169
168
  ];
170
169
  /** 条件出现的工具数(`REGISTERED_TOOLS` 的**末段**;`assertManifestProse` 用) */
171
- const CONDITIONAL_TOOL_COUNT = 3;
170
+ const CONDITIONAL_TOOL_COUNT = 2;
172
171
  //#endregion
173
172
  export { CONDITIONAL_TOOL_COUNT, REGISTERED_TOOLS, assertManifestProse, verifyToolConsistency };
@@ -58,6 +58,6 @@ export declare function assertManifestProse(manifestPath: string, readmePaths: r
58
58
  * `review`(C 档,调引擎 `compliance`)/`index`(调 P1 的生成器)/`status` ⇒ **14**。
59
59
  * 同规格:**条件可见与否不影响这里列它**(本常量 = "插件**具备**的工具面")。
60
60
  */
61
- export declare const REGISTERED_TOOLS: readonly ["container_fs", "cognitive_trajectory", "dashboard", "container_git", "msm", "praxis", "ontology", "serenity-skill-creator", "localstore", "container_admin", "browser_slot", "im-bridge", "diagram", "reconstruct"];
61
+ export declare const REGISTERED_TOOLS: readonly ["container_fs", "cognitive_trajectory", "dashboard", "container_git", "msm", "praxis", "ontology", "serenity-skill-creator", "localstore", "container_admin", "browser_slot", "im-bridge", "diagram"];
62
62
  /** 条件出现的工具数(`REGISTERED_TOOLS` 的**末段**;`assertManifestProse` 用) */
63
- export declare const CONDITIONAL_TOOL_COUNT = 3;
63
+ export declare const CONDITIONAL_TOOL_COUNT = 2;
@@ -1,8 +1,7 @@
1
1
  import { d as readCccName, i as findGitRoot, l as pathInside, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-DSMqTrRU.js";
2
2
  import { u as ACC_VERSION } from "./rules-BYeykzys.js";
3
- import { r as checkRegistryQuality } from "./service-DF23HvHY.js";
3
+ import { i as readDshVersion, t as hostContractReport, v as checkRegistryQuality } from "./contract-B0uRA4S2.js";
4
4
  import { a as wakeSchedulerState, p as listWakes } from "./scheduler-pOtONqPy.js";
5
- import { n as readDshVersion, s as hostContractReport } from "./status-BwfDsakn.js";
6
5
  import { resolve } from "node:path";
7
6
  import { existsSync, readFileSync, statSync } from "node:fs";
8
7
  //#region src/surface/observation.ts
@@ -2,7 +2,7 @@ import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
2
  import { n as agentCwdFor, r as cccRootForCwd, u as hostService } from "./ccc-roots-B6dJON2X.js";
3
3
  import { F as isoLocal, b as parseTrajectoryCode, f as extractSessionMdPathFromText, m as getActiveSessionInfo, v as namingTitleFor, w as sessionEvents, y as parseSessionContextFromEvents } from "./bind-file-Dy6Qmm7z.js";
4
4
  import { c as replacesDefaultIdentity } from "./profile-CRcW3ifg.js";
5
- import { a as trajectoryConstraintFor } from "./session-CA4rNuiV.js";
5
+ import { a as trajectoryConstraintFor } from "./session-BMaTNjK1.js";
6
6
  import { a as ACC_MESSAGE_KIND, d as readLastBound, n as deliver, r as makeInjection, s as appendBound } from "./injection-ME-aoZVl.js";
7
7
  import { basename, dirname, join, resolve } from "node:path";
8
8
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
@@ -0,0 +1,47 @@
1
+ export interface FullReadOutcome {
2
+ /** 改写后的 content;`null` = 不接管(调用方必须原样放行) */
3
+ text: string | null;
4
+ /** 为什么没接管(诊断用;`null` = 已接管) */
5
+ reason: string | null;
6
+ }
7
+ /**
8
+ * 判「这次 read 是不是在读 SESSION.md」。
9
+ *
10
+ * ⚠️ 用 `basename` 精确比,⛔ 不用 `includes('SESSION')`:
11
+ * 后者会把 `SESSION-archive-2026-11-20.md`(几百 KB 的归档)也一起接管,
12
+ * 那是**本模块最危险的一种误判** —— 归档本来就该分次读。
13
+ */
14
+ export declare function isSessionMdRead(filePath: unknown): boolean;
15
+ /**
16
+ * 把宿主产出的「前 N 行」接续成全文。
17
+ *
18
+ * @param content 宿主给模型看的文本(单个 text 块的内容)
19
+ * @param absolutePath 真实文件路径(用于读全文;读不到就放行)
20
+ * @returns `text=null` 表示不接管
21
+ */
22
+ export declare function extendToWholeFile(content: string, absolutePath: string): FullReadOutcome;
23
+ /**
24
+ * 从一次成功 read 的 content 里取**单个 text 块**的正文。
25
+ * 非单块 / 非 text ⇒ `null`(放行)。
26
+ */
27
+ export declare function singleTextOf(content: unknown): string | null;
28
+ /**
29
+ * 注册读全文接管(`index.ts` 的 apply 调用)。
30
+ *
31
+ * ## 🔴 三处必须守住的边界
32
+ *
33
+ * ① **只改 `content`,⛔ 绝不动 `value`** —— 宿主源码对此有硬断言:
34
+ * 同时给两者会 `throw TypeError("cannot replace both value and content")`。
35
+ * 落到实处:`surface/usage.ts` 读的是 `value`,动它就会**打断用量统计**。
36
+ * ② **`isError` 一律放行** —— 失败的读取没有正文可接续。
37
+ * ③ **本钩子永不抛** —— 它挂在每轮都跑的返回路径上;抛一次等于用一次优化打断会话。
38
+ * `try/catch` 兜底后返回 `next()`(下游其他人的决策照旧)。
39
+ *
40
+ * ## 与既有 `tools/post-execute` 消费者的关系
41
+ *
42
+ * 本仓另有一处同钩子(keeper 计分/提醒/体积告示)。两者在**不同文件里各注册一次**,
43
+ * 宿主按 waterfall 串联 ⇒ 谁先谁后不影响正确性:本钩子只碰 `content`,
44
+ * 那一处只碰 `additionalContexts`。**这里刻意不合并**,因为合并会让
45
+ * 「一次读文件」和「每轮计分」产生编译期耦合。
46
+ */
47
+ export declare function registerSessionMdFullRead(ctx: unknown): void;
@@ -4,7 +4,7 @@ import { F as isoLocal, w as sessionEvents } from "./bind-file-Dy6Qmm7z.js";
4
4
  import { d as WAKE_CATCH_UP_MS, l as listCroCognitiveTrajectories } from "./scheduler-pOtONqPy.js";
5
5
  import { n as readSimpleSettings } from "./settings-YC-csZus.js";
6
6
  import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-DBoO0GSO.js";
7
- import { containerClocks, containerWakes } from "./observation-DiD_yJjS.js";
7
+ import { containerClocks, containerWakes } from "./observation-L-KQr5RL.js";
8
8
  //#region src/trajectory/live.ts
9
9
  /**
10
10
  * trajectory/live.ts — 进程内 live 会话取数 + 精简诊断
@@ -2910,7 +2910,10 @@ function trajectoryConstraintMsmGate(root, sessionId, action, name) {
2910
2910
  if (!name || !profile.msms.includes(name)) return { reject: "MSM not allowed" };
2911
2911
  return {};
2912
2912
  }
2913
- if (action === "list") return { whitelist: profileMsmWhitelist(profile) };
2913
+ if (action === "list") {
2914
+ if (profile.msms === void 0) return {};
2915
+ return { whitelist: profileMsmWhitelist(profile) };
2916
+ }
2914
2917
  return {};
2915
2918
  }
2916
2919
  //#endregion
@@ -77,7 +77,6 @@
77
77
  *
78
78
  * @see AGENT_SESSIONS/2026-08-24--S142--dsh-serenity-plugin 长期维护/proposals/2026-11-06T0050-a3f1-reconstruct-tool-proposal.md
79
79
  */
80
- import type { Agent } from '@deepseek-ai/dsh-agent';
81
80
  /**
82
81
  * 触发阈值:**10 亿**累计 token(owner 2026-11-06 裁「我这有好几个十亿的」+ 截图 1372M)。
83
82
  *
@@ -116,13 +115,11 @@ export declare function readTokenTotals(ctx: unknown, session: unknown): TokenTo
116
115
  */
117
116
  export declare function cumulativeTokens(totals: TokenTotals): number;
118
117
  /**
119
- * 当前宿主是否支持 `register()` 的第二参数(工具准入条件)。
118
+ * 该会话此刻是否已达阈值(keeper 提醒侧用它**记录**分流路径,不参与注入正文)。
120
119
  *
121
- * 判据 = 宿主版本 ≥ `0.2.2-rc.1`(`ToolRegistrationOptions` 首次出现的档)。
122
- * 读不到版本 ⇒ `false`(保守:不传第二参数 ⇒ 退化成"常驻可见",而不是赌它支持)。
120
+ * 🔴 **2026-11-20**:原注释写「`when` 与 keeper 提醒共用」—— `when` 已随工具面删除,
121
+ * 现在**只剩 keeper 这一处**调用(`seams/cognitive-trajectory-lifecycle.ts`)。
123
122
  */
124
- export declare function supportsActivation(): boolean;
125
- /** 该会话此刻是否已达阈值(`when` 与 keeper 提醒**共用**这一条判据) */
126
123
  export declare function shouldOfferReconstruct(ctx: unknown, session: unknown): boolean;
127
124
  /** 交接走哪条路(`in-place` = 原地清空;`new-log` = 另开日志并归档旧的) */
128
125
  export type HandoverPath = 'in-place' | 'new-log';
@@ -155,25 +152,22 @@ interface ReconstructDiagState {
155
152
  }
156
153
  /** 测试/调试:读诊断状态 */
157
154
  export declare function reconstructDiagSnapshot(): ReconstructDiagState;
158
- /** 测试/调试:清空诊断状态(跨用例隔离) */
159
- export declare function __resetReconstructDiagForTest(): void;
160
155
  /**
161
- * 造 `when` 回调:**答"这一步要不要把这个工具放出来"**,并顺带落一次节流的观测。
162
- *
163
- * 为什么观测不能省:owner 要的第一件事是"达阈值才出现",而**"它到底读到了多少"只有真机答得上**
164
- * (宿主的投影在本会话能否读出 1391 M 级 —— 这是方案阶段明确未验的那一格)。
165
- * 观测落盘让**第一次真机运行**同时完成"验投影"与"验功能",不必再另写一次性探针
166
- * (探针验的是"我这样调能读懂",诊断文件验的是**真实现每步真的算出什么** —— 后者才是上生产的那个数)。
167
- *
168
- * 🔴 三条硬约束(都来自宿主契约,逐字):
169
- * ① **绝不抛**(rejection fails step preparation);
170
- * ② **不改变任何注册、不启动任何工具工作**(契约:*"Conditions must not mutate registrations
171
- * or start tool work"*);
172
- * ③ **便宜** —— 每步都会跑 ⇒ 落盘按会话**节流 60s**。
156
+ * **改道观测**(2026-11-20 从已删的 `makeReconstructWhen` 搬来)——见 `tools/cognitive-trajectory.ts` 的调用处。
157
+ *
158
+ * 判据:`case 'rebuild'` 那里**已经**读完了四桶并判过阈值,多写一条诊断是零成本;
159
+ * 而那条读数要回答的「机制到底读到了多少」,**只在真要改道时才需要**。
160
+ *
161
+ * @param cumulative `null` = 读不到投影(⛔ 不写 0 —— 那会让"读不到"与"真的是 0"同形)
173
162
  */
174
- export declare function makeReconstructWhen(ctx: unknown): (context: {
175
- agent?: Agent;
176
- }) => boolean;
163
+ export declare function writeReconstructDiagForRoute(root: string, input: {
164
+ sessionId: string;
165
+ cumulative: number | null;
166
+ threshold: number;
167
+ rerouted: boolean;
168
+ }): void;
169
+ /** 测试/调试:清空诊断状态(跨用例隔离) */
170
+ export declare function __resetReconstructDiagForTest(): void;
177
171
  interface PendingReconstruct {
178
172
  /** 继续锚点(与 rebuild 同源构造,末尾多一行交代上一代) */
179
173
  anchor: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.137.11",
4
- "description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:14 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin/browser_slot;另三个 im-bridge/diagram/reconstruct 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表 + 浏览器槽位管理(≤20 个独立 profile 的 Chrome 槽位,带占用归属与异常时向所属会话反向注入提醒)。轨迹声明 = 轨迹目录下的 trajectory.json(约束面 + 旧标识 uid + CRO 机器绑定 cro.host;旧名 trajectory-constraint.json / skiff.json 仍在读取族里);轨迹提示词 = 轨迹目录下的 PROMPT.md(一条轨迹「是谁、按什么章程工作」,所有轨迹通用,追加在容器层与质量层之后,不替换它们)。适配 DSH 0.1.7-rc.1 / 0.2.0-rc.1 / 0.2.1-rc.1(三档)。",
3
+ "version": "1.137.13",
4
+ "description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:13 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin/browser_slot;另两个 im-bridge/diagram 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表 + 浏览器槽位管理(≤20 个独立 profile 的 Chrome 槽位,带占用归属与异常时向所属会话反向注入提醒)。轨迹声明 = 轨迹目录下的 trajectory.json(约束面 + 旧标识 uid + CRO 机器绑定 cro.host;旧名 trajectory-constraint.json / skiff.json 仍在读取族里);轨迹提示词 = 轨迹目录下的 PROMPT.md(一条轨迹「是谁、按什么章程工作」,所有轨迹通用,追加在容器层与质量层之后,不替换它们)。适配 DSH 0.1.7-rc.1 / 0.2.0-rc.1 / 0.2.1-rc.1(三档)。",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",