@shgroup/dsh-serenity-hooks 1.137.13 → 1.137.14
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 +1 -1
- package/lib/index.js +46 -20
- package/lib/seams/session-md-full-read.d.ts +11 -3
- package/package.json +1 -1
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-serenity-hooks",
|
|
3
|
-
"version": "1.137.
|
|
3
|
+
"version": "1.137.14",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "宁静号 ACC harness(Native Cordis 插件):给 DSH 装一个「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(三档,deepseek-ai/deepseek-harness)。",
|
|
6
6
|
"engines": {
|
package/lib/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { a as registerImAccountImpl, i as normalizeAccountChannel, n as getImAcc
|
|
|
19
19
|
import { createRequire } from "node:module";
|
|
20
20
|
import z from "@deepseek-ai/schemastery";
|
|
21
21
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
22
|
-
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
22
|
+
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
23
23
|
import { appendFileSync, chmodSync, closeSync, cpSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, utimesSync, writeFileSync } from "node:fs";
|
|
24
24
|
import { execFileSync, spawn } from "node:child_process";
|
|
25
25
|
import { homedir, platform } from "node:os";
|
|
@@ -8609,16 +8609,25 @@ function isSessionMdRead(filePath) {
|
|
|
8609
8609
|
/**
|
|
8610
8610
|
* 把宿主产出的「前 N 行」接续成全文。
|
|
8611
8611
|
*
|
|
8612
|
-
*
|
|
8613
|
-
*
|
|
8612
|
+
* 🔴 **路径来源(真机踩过,v1.137.13 发布后当场发现)**:调用方传进来的 `file_path`
|
|
8613
|
+
* 往往是**相对路径**(如 `AGENT_SESSIONS/<轨迹>/SESSION.md`),而 `readFileSync` 按
|
|
8614
|
+
* **进程 cwd** 解析 —— 宿主进程的 cwd 不是 CCC 根 ⇒ 读到 ENOENT ⇒ 本模块静默放行,
|
|
8615
|
+
* **功能看起来"没生效"而实际是路径取错了**。
|
|
8616
|
+
* ⇒ 权威路径 = 宿主信封里的 `<path>`(`displayPath`,实测是绝对路径)。
|
|
8617
|
+
* ⚠️ 两者都试:**先信封、后参数**,并都要求绝对(相对路径无法可靠解析,⛔ 不猜)。
|
|
8618
|
+
* 安全性由**接缝核验**兜底:读错了文件 ⇒ 最后一行对不上 ⇒ 放行。
|
|
8619
|
+
*
|
|
8620
|
+
* @param content 宿主给模型看的文本(单个 text 块的内容)
|
|
8621
|
+
* @param hintPath 调用参数里的路径(兜底用;通常是相对路径)
|
|
8614
8622
|
* @returns `text=null` 表示不接管
|
|
8615
8623
|
*/
|
|
8616
|
-
function extendToWholeFile(content,
|
|
8624
|
+
function extendToWholeFile(content, hintPath) {
|
|
8617
8625
|
const m = ENVELOPE_RE.exec(content);
|
|
8618
8626
|
if (!m) return {
|
|
8619
8627
|
text: null,
|
|
8620
8628
|
reason: "envelope-unrecognized"
|
|
8621
8629
|
};
|
|
8630
|
+
const candidates = [m[1], hintPath ?? ""].filter((p) => p.length > 0 && isAbsolute(p));
|
|
8622
8631
|
const body = m[2];
|
|
8623
8632
|
const split = body.lastIndexOf("\n\n");
|
|
8624
8633
|
if (split < 0) return {
|
|
@@ -8654,25 +8663,42 @@ function extendToWholeFile(content, absolutePath) {
|
|
|
8654
8663
|
text: null,
|
|
8655
8664
|
reason: "body-empty"
|
|
8656
8665
|
};
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8666
|
+
const lastGiven = given[given.length - 1];
|
|
8667
|
+
const readLines = (p) => {
|
|
8668
|
+
try {
|
|
8669
|
+
const lines = readFileSync(p, "utf-8").split("\n");
|
|
8670
|
+
if (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
|
|
8671
|
+
return lines;
|
|
8672
|
+
} catch {
|
|
8673
|
+
return null;
|
|
8674
|
+
}
|
|
8675
|
+
};
|
|
8676
|
+
let all = null;
|
|
8677
|
+
let seamMismatch = false;
|
|
8678
|
+
for (const p of candidates) {
|
|
8679
|
+
const lines = readLines(p);
|
|
8680
|
+
if (lines === null) continue;
|
|
8681
|
+
if (lines.length <= lastGiven.number) {
|
|
8682
|
+
seamMismatch = true;
|
|
8683
|
+
break;
|
|
8684
|
+
}
|
|
8685
|
+
if (lines[lastGiven.number - 1] !== lastGiven.text) {
|
|
8686
|
+
seamMismatch = true;
|
|
8687
|
+
break;
|
|
8688
|
+
}
|
|
8689
|
+
all = lines;
|
|
8690
|
+
break;
|
|
8691
|
+
}
|
|
8692
|
+
if (all === null) {
|
|
8693
|
+
if (seamMismatch) return {
|
|
8694
|
+
text: null,
|
|
8695
|
+
reason: "seam-mismatch"
|
|
8696
|
+
};
|
|
8661
8697
|
return {
|
|
8662
8698
|
text: null,
|
|
8663
|
-
reason: "file-unreadable"
|
|
8699
|
+
reason: candidates.length === 0 ? "no-absolute-path" : "file-unreadable"
|
|
8664
8700
|
};
|
|
8665
8701
|
}
|
|
8666
|
-
if (all.length > 0 && all[all.length - 1] === "") all.pop();
|
|
8667
|
-
const lastGiven = given[given.length - 1];
|
|
8668
|
-
if (all.length <= lastGiven.number) return {
|
|
8669
|
-
text: null,
|
|
8670
|
-
reason: "nothing-left-to-extend"
|
|
8671
|
-
};
|
|
8672
|
-
if (all[lastGiven.number - 1] !== lastGiven.text) return {
|
|
8673
|
-
text: null,
|
|
8674
|
-
reason: "file-changed-since-read"
|
|
8675
|
-
};
|
|
8676
8702
|
const rest = all.slice(lastGiven.number).map((t, i) => `${lastGiven.number + 1 + i}: ${t}`);
|
|
8677
8703
|
const extendedBody = [...bodyLinesText.split("\n"), ...rest].join("\n");
|
|
8678
8704
|
const newFooter = `(End of file - total ${all.length} lines)`;
|
|
@@ -8724,7 +8750,7 @@ function registerSessionMdFullRead(ctx) {
|
|
|
8724
8750
|
if (ds?.kind === "block") return downstream;
|
|
8725
8751
|
const text = singleTextOf(result.content);
|
|
8726
8752
|
if (text === null) return downstream;
|
|
8727
|
-
const outcome = extendToWholeFile(singleTextOf(ds.content) ?? text,
|
|
8753
|
+
const outcome = extendToWholeFile(singleTextOf(ds.content) ?? text, typeof argPath === "string" ? argPath : void 0);
|
|
8728
8754
|
if (outcome.text === null) return downstream;
|
|
8729
8755
|
return {
|
|
8730
8756
|
...ds,
|
|
@@ -15,11 +15,19 @@ export declare function isSessionMdRead(filePath: unknown): boolean;
|
|
|
15
15
|
/**
|
|
16
16
|
* 把宿主产出的「前 N 行」接续成全文。
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* 🔴 **路径来源(真机踩过,v1.137.13 发布后当场发现)**:调用方传进来的 `file_path`
|
|
19
|
+
* 往往是**相对路径**(如 `AGENT_SESSIONS/<轨迹>/SESSION.md`),而 `readFileSync` 按
|
|
20
|
+
* **进程 cwd** 解析 —— 宿主进程的 cwd 不是 CCC 根 ⇒ 读到 ENOENT ⇒ 本模块静默放行,
|
|
21
|
+
* **功能看起来"没生效"而实际是路径取错了**。
|
|
22
|
+
* ⇒ 权威路径 = 宿主信封里的 `<path>`(`displayPath`,实测是绝对路径)。
|
|
23
|
+
* ⚠️ 两者都试:**先信封、后参数**,并都要求绝对(相对路径无法可靠解析,⛔ 不猜)。
|
|
24
|
+
* 安全性由**接缝核验**兜底:读错了文件 ⇒ 最后一行对不上 ⇒ 放行。
|
|
25
|
+
*
|
|
26
|
+
* @param content 宿主给模型看的文本(单个 text 块的内容)
|
|
27
|
+
* @param hintPath 调用参数里的路径(兜底用;通常是相对路径)
|
|
20
28
|
* @returns `text=null` 表示不接管
|
|
21
29
|
*/
|
|
22
|
-
export declare function extendToWholeFile(content: string,
|
|
30
|
+
export declare function extendToWholeFile(content: string, hintPath?: string): FullReadOutcome;
|
|
23
31
|
/**
|
|
24
32
|
* 从一次成功 read 的 content 里取**单个 text 块**的正文。
|
|
25
33
|
* 非单块 / 非 text ⇒ `null`(放行)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.137.
|
|
3
|
+
"version": "1.137.14",
|
|
4
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": {
|