@shgroup/dsh-serenity-hooks 1.18.1 → 1.18.3

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.18.1",
3
+ "version": "1.18.3",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):真实 DSH 工具 cc_fs/session/acc_msm/eap/neat/cce/loop + 拦截缝机械约束(safe-mode/路径守卫/会话落盘)。适配 DSH 公开版(0.1.0-rc,deepseek-ai/deepseek-harness)。私有(dsh-external 组织)。",
6
6
  "engines": {
package/lib/index.js CHANGED
@@ -3524,8 +3524,9 @@ const DEFAULT_COMPACTION_TOOLS = [
3524
3524
  "grep",
3525
3525
  "todo_write"
3526
3526
  ];
3527
- /** 默认首轮锚定问题(用户指定:介绍宁静号,200 字以内) */
3528
- const DEFAULT_ANCHOR_MESSAGE = "请介绍当前宁静号,它是什么,为了什么,200字以内回答";
3527
+ /** 默认首轮锚定消息(用户指定:persona 设定 + we/us 人称——首轮模型以 we/us 自称,
3528
+ * 对齐 anchored 实测的 "we" 轨迹特征) */
3529
+ const DEFAULT_ANCHOR_MESSAGE = "You are a helpful software engineer assistant.The personal pronoun is us/we.";
3529
3530
  /** 构建一个 epoch 感知晋升跟踪器(纯逻辑,可单测) */
3530
3531
  function createEpochPromotion(promoteEvents) {
3531
3532
  /** sessionId -> { boundary, promoted } */
@@ -3621,10 +3622,11 @@ function resolveBootstrapSettings(opts) {
3621
3622
  if (promoteOn !== "either" && promoteOn !== "tool-call" && promoteOn !== "assistant-message") throw new TypeError(`bootstrap: promoteOn must be one of "tool-call", "assistant-message", "either"; got ${JSON.stringify(promoteOn)}`);
3622
3623
  return {
3623
3624
  bootstrapTools: stringList(opts.bootstrapTools, "bootstrapTools", DEFAULT_BOOTSTRAP_TOOLS),
3624
- promoteEvents: PROMOTE_EVENTS[promoteOn],
3625
+ promoteEvents: opts.zeroTools ? PROMOTE_EVENTS["assistant-message"] : PROMOTE_EVENTS[promoteOn],
3625
3626
  suppressedSources: sourceList(opts.suppressedContextSources, "suppressedContextSources", DEFAULT_SUPPRESSED_SOURCES),
3626
3627
  compactionTools: stringList(opts.compactionTools, "compactionTools", DEFAULT_COMPACTION_TOOLS),
3627
- anchorMessage: typeof opts.anchorMessage === "string" && opts.anchorMessage.length > 0 ? opts.anchorMessage : DEFAULT_ANCHOR_MESSAGE
3628
+ anchorMessage: typeof opts.anchorMessage === "string" && opts.anchorMessage.length > 0 ? opts.anchorMessage : DEFAULT_ANCHOR_MESSAGE,
3629
+ zeroTools: opts.zeroTools === true
3628
3630
  };
3629
3631
  }
3630
3632
  /**
@@ -3653,15 +3655,30 @@ function readBootstrapConfig(agent) {
3653
3655
  promoteOn: b?.promoteOn,
3654
3656
  suppressedContextSources: b?.suppressedContextSources,
3655
3657
  compactionTools: b?.compactionTools,
3656
- anchorMessage: b?.anchorMessage
3658
+ anchorMessage: b?.anchorMessage,
3659
+ zeroTools: b?.zeroTools
3657
3660
  });
3658
3661
  }
3659
3662
  function registerBootstrap(ctx) {
3660
3663
  const settingsByRoot = /* @__PURE__ */ new Map();
3661
- const tracker = createEpochPromotion(/* @__PURE__ */ new Set(["tool/call", "assistant/message"]));
3664
+ const trackers = /* @__PURE__ */ new Map();
3665
+ const trackerFor = (root, settings) => {
3666
+ let t = trackers.get(root);
3667
+ if (!t) {
3668
+ t = createEpochPromotion(settings.promoteEvents);
3669
+ trackers.set(root, t);
3670
+ }
3671
+ return t;
3672
+ };
3662
3673
  ctx.on("session/event", (session, event) => {
3663
3674
  try {
3664
- tracker.observe(session, event);
3675
+ const cwd = session?.header?.cwd;
3676
+ if (typeof cwd !== "string") return;
3677
+ const root = findSerenityRoot(cwd);
3678
+ if (!root) return;
3679
+ const settings = settingsByRoot.get(root) ?? readBootstrapConfig({ session });
3680
+ settingsByRoot.set(root, settings);
3681
+ trackerFor(root, settings).observe(session, event);
3665
3682
  } catch {}
3666
3683
  });
3667
3684
  ctx.on("agent/inbox/inserted", ({ agent, message }) => {
@@ -3708,13 +3725,29 @@ function registerBootstrap(ctx) {
3708
3725
  if (!root) return assembled;
3709
3726
  const settings = settingsByRoot.get(root) ?? readBootstrapConfig(agent);
3710
3727
  settingsByRoot.set(root, settings);
3711
- const status = tracker.status(agent);
3728
+ const status = trackerFor(root, settings).status(agent);
3712
3729
  if (status.promoted) return assembled;
3713
- const keep = new Set(settings.bootstrapTools);
3714
- if (status.boundary >= 0) for (const toolName of settings.compactionTools) keep.add(toolName);
3715
3730
  const tools = assembled.tools;
3716
3731
  if (!Array.isArray(tools)) return assembled;
3717
3732
  const available = new Set(tools.map((tool) => tool.name).filter((n) => typeof n === "string"));
3733
+ if (settings.zeroTools) {
3734
+ if (status.boundary < 0) return {
3735
+ ...assembled,
3736
+ tools: []
3737
+ };
3738
+ const keep = new Set(settings.compactionTools);
3739
+ const missing = [...keep].filter((name) => !available.has(name));
3740
+ if (missing.length > 0) {
3741
+ warnOnce(`expected compaction tools missing=${JSON.stringify(missing)} — bootstrap disabled, full catalog exposed`);
3742
+ return assembled;
3743
+ }
3744
+ return {
3745
+ ...assembled,
3746
+ tools: tools.filter((tool) => typeof tool.name === "string" && keep.has(tool.name))
3747
+ };
3748
+ }
3749
+ const keep = new Set(settings.bootstrapTools);
3750
+ if (status.boundary >= 0) for (const toolName of settings.compactionTools) keep.add(toolName);
3718
3751
  const missing = [...keep].filter((name) => !available.has(name));
3719
3752
  if (missing.length > 0) {
3720
3753
  warnOnce(`expected bootstrap tools missing=${JSON.stringify(missing)} — bootstrap disabled, full catalog exposed`);
@@ -3733,9 +3766,11 @@ function registerBootstrap(ctx) {
3733
3766
  const decision = await next();
3734
3767
  if (decision.kind === "reject") return decision;
3735
3768
  try {
3736
- if (!agentRoot(agent)) return decision;
3737
- const settings = readBootstrapConfig(agent);
3738
- if (tracker.status(agent).promoted || settings.suppressedSources.size === 0) return decision;
3769
+ const root = agentRoot(agent);
3770
+ if (!root) return decision;
3771
+ const settings = settingsByRoot.get(root) ?? readBootstrapConfig(agent);
3772
+ settingsByRoot.set(root, settings);
3773
+ if (trackerFor(root, settings).status(agent).promoted || settings.suppressedSources.size === 0) return decision;
3739
3774
  const messages = decision.messages;
3740
3775
  if (!Array.isArray(messages)) return decision;
3741
3776
  const kept = messages.filter((message) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.18.1",
3
+ "version": "1.18.3",
4
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
5
  "license": "MIT",
6
6
  "repository": {