@shgroup/dsh-serenity-hooks 1.128.0 → 1.128.2

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/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-serenity-hooks",
3
- "version": "1.128.0",
3
+ "version": "1.128.2",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):给 DSH 装一个「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(三档,deepseek-ai/deepseek-harness)。",
6
6
  "engines": {
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ import { a as findSerenityRoot$1, d as readCccName, g as resolveInside, l as pat
4
4
  import { A as useSession, C as resolveSessionByTitle, D as showSession, E as setActiveSessionInfo, F as isoLocal, I as localFileStamp, M as TRAJECTORY_LEGACY_FILENAMES, O as summarize, S as readTrajectoryUid, T as sessionsRoot, _ as listSessions, b as parseTrajectoryCode, c as UID_FILENAME, d as createSession, f as extractSessionMdPathFromText, j as TRAJECTORY_FILENAME, k as trajectoryDescOf, l as archiveSession, m as getActiveSessionInfo, o as COGNITIVE_TRAJECTORY_ACTIONS, p as findSession, u as clearActiveSessionInfo, v as namingTitleFor, w as sessionEvents, y as parseSessionContextFromEvents } from "./bind-file-B0TuOP89.js";
5
5
  import { n as checkLocalstoreGitCompliance, o as readStore, s as runLocalStore, t as LOCALSTORE_SCOPES } from "./service-BRUHmVFn.js";
6
6
  import { d as findPackageRoot, i as constraintSystemPromptSource, l as resolveConstraintSystemPrompt, r as constraintCognitiveTrajectory, t as TRAJECTORY_CONSTRAINT_HINT, u as ACC_VERSION } from "./rules-BYeykzys.js";
7
- import { C as runMsmAsync, S as runMsm, T as setWeixinSendEndpoint, _ as ACC_CATALOG, a as loadOpencodeSkill, b as findEntry, c as summarizeHostContract, f as forgetNonCccToolVisibility, g as forgetToolVisibility, h as syncToolVisibility, i as listOpencodeSkillDirs, m as registerGuards, n as readDshVersion, o as compareSemver, r as setSafeMode, s as hostContractReport, t as getStatus, v as CCC_CONFIG_REFERENCE, w as docsPointer, x as loadMsmEntries } from "./status-O7MPoKFy.js";
7
+ import { C as runMsmAsync, S as runMsm, T as setWeixinSendEndpoint, _ as ACC_CATALOG, a as loadOpencodeSkill, b as findEntry, c as summarizeHostContract, f as forgetNonCccToolVisibility, g as forgetToolVisibility, h as syncToolVisibility, i as listOpencodeSkillDirs, m as registerGuards, n as readDshVersion, o as compareSemver, r as setSafeMode, s as hostContractReport, t as getStatus, v as CCC_CONFIG_REFERENCE, w as docsPointer, x as loadMsmEntries } from "./status-thzfjL_4.js";
8
8
  import { c as replacesDefaultIdentity, i as listTrajectoryConstraints, l as trajectoryCodeForSession, n as findDirNameByCode, o as readTrajectoryConstraintAt, r as isTrajectoryConstrained, s as readTrajectoryConstraintByCode, t as TRAJECTORY_CONSTRAINT_FILENAME } from "./profile-DpxC9HtB.js";
9
9
  import { A as TRAJECTORY_PROMPT_FILENAME, C as recordToolUsage, D as buildResourceNameSuffix, E as buildResourceIndex, O as isSafeSkillName, S as verifyTotpCode, T as SKILL_ONTOLOGY_FILE, _ as projectKnownWorkspaces, a as trajectoryConstraintFor, b as FACE_PORTS, c as trajectoryWorkspaceMdPath, d as splitModel, f as registerCognitiveTrajectorySkillSection, g as migrateLegacyLocalstore, h as applyWirePatch, i as getTrajectoryAgent, j as hasTrajectoryPrompt, k as truncateContent, l as unregisterTrajectorySession, m as registerEntrySkillSectionGlobal, n as deliverToTrajectory, o as trajectoryConstraintMsmGate, p as registerEntrySkillSection, r as ensureWorkspacePromptSection, s as trajectoryConstraintParticipates, t as createTrajectoryAgent, u as workspaceCognitiveTrajectoryLine, v as readAdvancedSettings, w as REFERENCE_DIR, x as MECHANISM_PORTS, y as toWire } from "./session-B5CKVEIF.js";
10
10
  import { a as ACC_MESSAGE_KIND, d as readLastBound, f as resolveSessionCognitiveTrajectoryLabel, i as toMessage, l as findTrajectoryOfSession, n as deliver, o as PLUGIN_SOURCE, r as makeInjection, s as appendBound, u as listBoundSessionIds } from "./injection-CKx49Mlf.js";
@@ -515,7 +515,7 @@ const KIT_ACTIONS = [
515
515
  async function runKit(root, args, hostCtx) {
516
516
  switch (args.action) {
517
517
  case "health": {
518
- const { containerStatus } = await import("./observation-jNfDH9lC.js");
518
+ const { containerStatus } = await import("./observation-ryu83rOe.js");
519
519
  const s = containerStatus({
520
520
  root,
521
521
  hostCtx
@@ -561,7 +561,7 @@ async function runKit(root, args, hostCtx) {
561
561
  }
562
562
  case "diag": {
563
563
  if (hostCtx === void 0) throw new Error("diag requires the plugin context (live session data unavailable without it)");
564
- const { runDiag, renderDiag } = await import("./service-BGwhex36.js");
564
+ const { runDiag, renderDiag } = await import("./service-CTD39Kby.js");
565
565
  return renderDiag(await runDiag(hostCtx, root ?? ""));
566
566
  }
567
567
  default: throw new Error(`Unknown action: ${args.action}`);
@@ -20299,6 +20299,35 @@ function createBrowserSlotTool(ctx) {
20299
20299
  });
20300
20300
  }
20301
20301
  /**
20302
+ * 找出**所有**该被看守盯的 CCC 根。
20303
+ *
20304
+ * 🔴🔴 **为什么不能再用 `cccRootForCwd(process.cwd())`**(2026-11-09 真机实测,一个静默失效):
20305
+ * 宿主进程的 cwd 是**用户家目录**(`dashboard diag` 明写「进程 CCC:(无)」)
20306
+ * ⇒ `cccRootForCwd(process.cwd())` **恒返回 `null`** ⇒ `tick()` 第一行 `if (!root) return`
20307
+ * ⇒ **看守每一拍都直接返回,一次都没工作过**,而它没有任何报错、没有任何日志、台账上
20308
+ * 也看不出异常(`nudges` 一直是 0,与"没人在用槽位"读数相同)。
20309
+ *
20310
+ * 实测取证:把 b1 造成 `stale`(闲 55 分钟)、归属指向本轨迹、进程活着、
20311
+ * 连等两拍(23:11:21 过了)⇒ 台账 `nudges` 仍为 **0**。
20312
+ *
20313
+ * 判据(这条比修法值钱):**"装配了" ≠ "在工作"**。`registerSlotWatchman` 确实被调用、
20314
+ * `setInterval` 确实在跑、`tick` 确实被触发 —— 而它每次都在第一行静默返回。
20315
+ * 一个**永远走不到第二行**的定时器,在"有没有装配"这个读数上与健康的一模一样。
20316
+ *
20317
+ * 修法:用 `listCccs(ctx)` —— 它是「本机有哪些 CCC 根」**唯一的权威枚举**
20318
+ * (并集语义;`dashboard diag` 也是走它那一族)。⛔ 不用进程 cwd(那是服务启动目录,
20319
+ * 与会话无关);⛔ 不猜目录(猜出来的根会去读别人的台账)。
20320
+ *
20321
+ * ⚠️ 一个宿主进程服务多个 CCC(实测 3 个)⇒ 必须**逐个**看守,⛔ 不能只挑一个。
20322
+ */
20323
+ async function findWatchRoots(ctx) {
20324
+ try {
20325
+ return (await listCccs(ctx)).map((c) => c.root).filter((r) => typeof r === "string" && r.length > 0);
20326
+ } catch {
20327
+ return [];
20328
+ }
20329
+ }
20330
+ /**
20302
20331
  * 槽位看守(后台)—— owner 要的「反过来向唤醒这个浏览器的会话注入消息」就是这里。
20303
20332
  *
20304
20333
  * 🔴 为什么放在 ACC 而不是某个轨迹:**忘了关浏览器的不止一条轨迹**,而看守必须比任何
@@ -20306,12 +20335,15 @@ function createBrowserSlotTool(ctx) {
20306
20335
  *
20307
20336
  * ⚠️ 它**只提醒、不代为释放** —— 见 nudgeText 的判据:只有占用者知道那个浏览器还有没有用。
20308
20337
  */
20309
- function registerSlotWatchman(ctx, rootProvider) {
20338
+ function registerSlotWatchman(ctx) {
20310
20339
  let timer = null;
20311
20340
  const tick = async () => {
20312
- const root = rootProvider();
20313
- if (!root) return;
20314
- try {
20341
+ const roots = await findWatchRoots(ctx);
20342
+ if (roots.length === 0) {
20343
+ console.warn("[serenity-hooks] ⚠️ 槽位看守:未枚举到任何 CCC 根 ⇒ 本拍未扫描(不是\"无异常\")");
20344
+ return;
20345
+ }
20346
+ for (const root of roots) try {
20315
20347
  const res = await nudgeStaleSlots(root, async (r, target, message) => {
20316
20348
  const out = await sendToCognitiveTrajectory(ctx, r, target, message, "浏览器槽位看守");
20317
20349
  return {
@@ -20321,7 +20353,7 @@ function registerSlotWatchman(ctx, rootProvider) {
20321
20353
  });
20322
20354
  for (const n of res.nudged) console.log(`[serenity-hooks] 槽位看守:${slotLabel(n.slot)} (${n.state}) → ${n.trajectory || "(无归属)"} ${n.delivered ? "已注入" : "注入失败"}:${n.detail}`);
20323
20355
  } catch (err) {
20324
- console.warn(`[serenity-hooks] ✗ 槽位看守异常: ${String(err?.message ?? err)}`);
20356
+ console.warn(`[serenity-hooks] ✗ 槽位看守异常(${root}): ${String(err?.message ?? err)}`);
20325
20357
  }
20326
20358
  };
20327
20359
  timer = setInterval(tick, 3e5);
@@ -20616,7 +20648,7 @@ function apply(ctx, config) {
20616
20648
  registerCroTurnTracking(ctx);
20617
20649
  registerWakeScheduler(ctx);
20618
20650
  registerTrajectorySubscriptions(ctx, defaultSubscriptionDeps(ctx));
20619
- registerSlotWatchman(ctx, () => cccRootForCwd(process.cwd()));
20651
+ registerSlotWatchman(ctx);
20620
20652
  registerWeixinBridge(ctx);
20621
20653
  registerWeixinSendApi(ctx);
20622
20654
  registerWeixinOutputGuard(ctx);
@@ -1,6 +1,6 @@
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 { n as readDshVersion, s as hostContractReport, y as checkRegistryQuality } from "./status-O7MPoKFy.js";
3
+ import { n as readDshVersion, s as hostContractReport, y as checkRegistryQuality } from "./status-thzfjL_4.js";
4
4
  import { a as wakeSchedulerState, y as listWakes } from "./scheduler-CgjLs5_S.js";
5
5
  import { resolve } from "node:path";
6
6
  import { existsSync, readFileSync, statSync } from "node:fs";
@@ -4,7 +4,7 @@ import { F as isoLocal, w as sessionEvents } from "./bind-file-B0TuOP89.js";
4
4
  import { _ as WAKE_CATCH_UP_MS, h as listCroCognitiveTrajectories } from "./scheduler-CgjLs5_S.js";
5
5
  import { n as readSimpleSettings } from "./settings-CUabGkal.js";
6
6
  import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-C4oGjnC2.js";
7
- import { containerClocks, containerWakes } from "./observation-jNfDH9lC.js";
7
+ import { containerClocks, containerWakes } from "./observation-ryu83rOe.js";
8
8
  //#region src/trajectory/live.ts
9
9
  /**
10
10
  * trajectory/live.ts — 进程内 live 会话取数 + 精简诊断
@@ -632,7 +632,12 @@ function checkRegistryQuality(root) {
632
632
  detail: "no main() guard"
633
633
  });
634
634
  }
635
- for (const f of e.flags ?? []) if ("name" in f && /path|file|dir/i.test(f.name) && f.type !== "path") issues.push({
635
+ const isPathLikeFlagName = (name) => {
636
+ if (name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().split(/[-_.]+/).filter(Boolean).some((s) => PATH_LIKE_SEGMENTS.has(s))) return true;
637
+ if (EXEMPT_FROM_PATH_SUFFIX.has(name.toLowerCase())) return false;
638
+ return PATH_LIKE_SUFFIXES.some((suf) => name.toLowerCase().endsWith(suf));
639
+ };
640
+ for (const f of e.flags ?? []) if ("name" in f && isPathLikeFlagName(String(f.name)) && f.type !== "path") issues.push({
636
641
  name: e.name,
637
642
  check: "M4",
638
643
  detail: `flag --${f.name} should be type:"path"`
@@ -643,6 +648,33 @@ function checkRegistryQuality(root) {
643
648
  issues
644
649
  };
645
650
  }
651
+ /**
652
+ * 构成"路径型"的**整段**词。
653
+ * ⛔ 不要往里加 `profile` / `file` 之外的模糊词 —— 这份集合的每一次扩写都必须能说出
654
+ * "哪个 flag 因为它被正确识别了",否则它就只是在制造假阳。
655
+ */
656
+ const PATH_LIKE_SEGMENTS = /* @__PURE__ */ new Set([
657
+ "path",
658
+ "file",
659
+ "dir",
660
+ "folder",
661
+ "directory"
662
+ ]);
663
+ /**
664
+ * 连写形式(`outfile` / `indir` / `outpath`)的判据 = **词尾**。
665
+ * ⛔ 不加 `profile`:它以 `file` 结尾,但那个 flag 是**名字**不是路径。
666
+ * ⇒ 这一条正是本判据此前的假阳来源;把它排除在此,而不是把 profile 硬标成 path。
667
+ */
668
+ const PATH_LIKE_SUFFIXES = [
669
+ "file",
670
+ "path",
671
+ "dir"
672
+ ];
673
+ /**
674
+ * 名字以路径词结尾、但**语义上不是路径**的 flag(点名例外)。
675
+ * 每加一项都要能说出"为什么它不是路径",否则就是拿例外掩盖假阳。
676
+ */
677
+ const EXEMPT_FROM_PATH_SUFFIX = /* @__PURE__ */ new Set(["profile"]);
646
678
  function registryPathFor(root, _skill) {
647
679
  const cccName = readCccName(root) ?? "unknown";
648
680
  return join(root, ".opencode", "skills", cccName, "references", "mech-registry.json");
@@ -13,6 +13,29 @@
13
13
  */
14
14
  import type { Context } from 'cordis';
15
15
  export declare function createBrowserSlotTool(ctx: Context): import("@deepseek-ai/dsh-tools").ToolDefinition;
16
+ /**
17
+ * 找出**所有**该被看守盯的 CCC 根。
18
+ *
19
+ * 🔴🔴 **为什么不能再用 `cccRootForCwd(process.cwd())`**(2026-11-09 真机实测,一个静默失效):
20
+ * 宿主进程的 cwd 是**用户家目录**(`dashboard diag` 明写「进程 CCC:(无)」)
21
+ * ⇒ `cccRootForCwd(process.cwd())` **恒返回 `null`** ⇒ `tick()` 第一行 `if (!root) return`
22
+ * ⇒ **看守每一拍都直接返回,一次都没工作过**,而它没有任何报错、没有任何日志、台账上
23
+ * 也看不出异常(`nudges` 一直是 0,与"没人在用槽位"读数相同)。
24
+ *
25
+ * 实测取证:把 b1 造成 `stale`(闲 55 分钟)、归属指向本轨迹、进程活着、
26
+ * 连等两拍(23:11:21 过了)⇒ 台账 `nudges` 仍为 **0**。
27
+ *
28
+ * 判据(这条比修法值钱):**"装配了" ≠ "在工作"**。`registerSlotWatchman` 确实被调用、
29
+ * `setInterval` 确实在跑、`tick` 确实被触发 —— 而它每次都在第一行静默返回。
30
+ * 一个**永远走不到第二行**的定时器,在"有没有装配"这个读数上与健康的一模一样。
31
+ *
32
+ * 修法:用 `listCccs(ctx)` —— 它是「本机有哪些 CCC 根」**唯一的权威枚举**
33
+ * (并集语义;`dashboard diag` 也是走它那一族)。⛔ 不用进程 cwd(那是服务启动目录,
34
+ * 与会话无关);⛔ 不猜目录(猜出来的根会去读别人的台账)。
35
+ *
36
+ * ⚠️ 一个宿主进程服务多个 CCC(实测 3 个)⇒ 必须**逐个**看守,⛔ 不能只挑一个。
37
+ */
38
+ export declare function findWatchRoots(ctx: unknown): Promise<string[]>;
16
39
  /**
17
40
  * 槽位看守(后台)—— owner 要的「反过来向唤醒这个浏览器的会话注入消息」就是这里。
18
41
  *
@@ -21,6 +44,6 @@ export declare function createBrowserSlotTool(ctx: Context): import("@deepseek-a
21
44
  *
22
45
  * ⚠️ 它**只提醒、不代为释放** —— 见 nudgeText 的判据:只有占用者知道那个浏览器还有没有用。
23
46
  */
24
- export declare function registerSlotWatchman(ctx: Context, rootProvider: () => string | null): {
47
+ export declare function registerSlotWatchman(ctx: Context): {
25
48
  dispose: () => void;
26
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.128.0",
3
+ "version": "1.128.2",
4
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(三档)。",
5
5
  "license": "MIT",
6
6
  "repository": {