@shgroup/dsh-serenity-hooks 1.138.1 → 1.138.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 +1 -1
- package/lib/browser/domain-skill.d.ts +56 -0
- package/lib/index.js +114 -6
- 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.138.
|
|
3
|
+
"version": "1.138.3",
|
|
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": {
|
|
@@ -36,6 +36,42 @@ export declare function domainDir(cccRoot: string, urlOrHost: string): string |
|
|
|
36
36
|
export declare function domainSkillPath(cccRoot: string, urlOrHost: string): string | null;
|
|
37
37
|
/** 该域名是否已有说明书(**永远现算**,⛔ 不缓存进台账 —— 设计 §5.3) */
|
|
38
38
|
export declare function hasDomainSkill(cccRoot: string, urlOrHost: string): boolean;
|
|
39
|
+
/** 单个片段的体量上限(设计 §改动 3:⛔ 防止有人把整个库塞进来,那等于绕过 skill 体系) */
|
|
40
|
+
export declare const SNIPPET_MAX_BYTES: number;
|
|
41
|
+
/** 片段目录名(站点目录下) */
|
|
42
|
+
export declare const SNIPPET_DIR = "snippets";
|
|
43
|
+
export interface DomainSnippet {
|
|
44
|
+
/** 文件名(含扩展名) */
|
|
45
|
+
name: string;
|
|
46
|
+
/** 绝对路径 */
|
|
47
|
+
path: string;
|
|
48
|
+
/** 字节数 */
|
|
49
|
+
bytes: number;
|
|
50
|
+
}
|
|
51
|
+
/** 片段目录(站点目录下) */
|
|
52
|
+
export declare function snippetDir(cccRoot: string, urlOrHost: string): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* 列出该站可用的片段(**只读目录,不读内容**)。
|
|
55
|
+
*
|
|
56
|
+
* ## 只收 `.js`(owner 2026-11-24 裁「就是供 eval 用的 js 片段」)
|
|
57
|
+
*
|
|
58
|
+
* 🔴 **其它后缀一律不列** —— 不是说"跳过",是**结构性不认**:
|
|
59
|
+
* 设计稿那条裁决把"操作序列文档"整类删掉了 ⇒ 若这里放行 `.md`/`.txt`,
|
|
60
|
+
* 那类东西会借片段目录复活。
|
|
61
|
+
*
|
|
62
|
+
* ## 超限的不列,并**单独报出来**
|
|
63
|
+
*
|
|
64
|
+
* 一个 200 KB 的片段不该静默消失 —— 那与"我忘了写"在读数上同形。
|
|
65
|
+
* ⇒ 返回 `oversize` 列表,由调用方在回执里点名(⛔ 静默丢)。
|
|
66
|
+
*
|
|
67
|
+
* ⚠️ 排序:按文件名,稳定(⛔ 按 mtime —— 那会让回执在两次调用间变化而无语义)。
|
|
68
|
+
*/
|
|
69
|
+
export declare function listSnippets(cccRoot: string, urlOrHost: string): {
|
|
70
|
+
items: DomainSnippet[];
|
|
71
|
+
oversize: DomainSnippet[];
|
|
72
|
+
};
|
|
73
|
+
/** 读一个片段(供参考;**⛔ 本模块不执行它** —— 执行永远走既有的 `eval` 动作) */
|
|
74
|
+
export declare function loadSnippet(cccRoot: string, urlOrHost: string, name: string): string | null;
|
|
39
75
|
export interface DomainSkillHit {
|
|
40
76
|
/** 要追加到回执里的整段文本(含抬头与可能的截断记号) */
|
|
41
77
|
text: string;
|
|
@@ -49,6 +85,26 @@ export interface DomainSkillHit {
|
|
|
49
85
|
* 读失败(权限、半写状态)也返回 `null` —— 打开页面的主流程**不因说明书而失败**。
|
|
50
86
|
*/
|
|
51
87
|
export declare function loadDomainSkill(cccRoot: string, urlOrHost: string): DomainSkillHit | null;
|
|
88
|
+
/**
|
|
89
|
+
* 片段的注入尾巴(设计 §改动 3)—— **只列清单,⛔ 不注入内容、⛔ 不执行**。
|
|
90
|
+
*
|
|
91
|
+
* ## 为什么只给清单而不给内容
|
|
92
|
+
*
|
|
93
|
+
* owner 裁决原话:「就是供 eval 用的 js 片段」。片段的价值是**可复用的认知**
|
|
94
|
+
* (下次不用重新摸索选择器),而它的用法是:模型读了说明书 → 看到这里有几支片段 →
|
|
95
|
+
* **自己决定**要不要 `eval` 其中一支。
|
|
96
|
+
*
|
|
97
|
+
* 🔴 若把内容也注进去,回执体量会失控(一支片段可达 16 KB),
|
|
98
|
+
* 而且**等于替它做了"要不要用"的决定** —— 那不该由注入层替它做。
|
|
99
|
+
*
|
|
100
|
+
* ## 为什么超限的要单独点名
|
|
101
|
+
*
|
|
102
|
+
* 一支 200 KB 的片段若静默消失,与「我忘了写」在读数上同形。
|
|
103
|
+
* ⇒ 明确告诉它"有这么个文件,但它太大没被采用",并给路径。
|
|
104
|
+
*
|
|
105
|
+
* @returns 追加文本;无片段 ⇒ **空串**(未命中零噪声,与说明书同一口径)
|
|
106
|
+
*/
|
|
107
|
+
export declare function snippetTail(cccRoot: string, urlOrHost: string): string;
|
|
52
108
|
export interface DomainVisit {
|
|
53
109
|
/** 累计打开次数 */
|
|
54
110
|
opens: number;
|
package/lib/index.js
CHANGED
|
@@ -22590,6 +22590,73 @@ function hasDomainSkill(cccRoot, urlOrHost) {
|
|
|
22590
22590
|
const p = domainSkillPath(cccRoot, urlOrHost);
|
|
22591
22591
|
return !!p && existsSync(p);
|
|
22592
22592
|
}
|
|
22593
|
+
/** 单个片段的体量上限(设计 §改动 3:⛔ 防止有人把整个库塞进来,那等于绕过 skill 体系) */
|
|
22594
|
+
const SNIPPET_MAX_BYTES = 16384;
|
|
22595
|
+
/** 片段目录名(站点目录下) */
|
|
22596
|
+
const SNIPPET_DIR = "snippets";
|
|
22597
|
+
/** 片段目录(站点目录下) */
|
|
22598
|
+
function snippetDir(cccRoot, urlOrHost) {
|
|
22599
|
+
const d = domainDir(cccRoot, urlOrHost);
|
|
22600
|
+
return d ? join(d, SNIPPET_DIR) : null;
|
|
22601
|
+
}
|
|
22602
|
+
/**
|
|
22603
|
+
* 列出该站可用的片段(**只读目录,不读内容**)。
|
|
22604
|
+
*
|
|
22605
|
+
* ## 只收 `.js`(owner 2026-11-24 裁「就是供 eval 用的 js 片段」)
|
|
22606
|
+
*
|
|
22607
|
+
* 🔴 **其它后缀一律不列** —— 不是说"跳过",是**结构性不认**:
|
|
22608
|
+
* 设计稿那条裁决把"操作序列文档"整类删掉了 ⇒ 若这里放行 `.md`/`.txt`,
|
|
22609
|
+
* 那类东西会借片段目录复活。
|
|
22610
|
+
*
|
|
22611
|
+
* ## 超限的不列,并**单独报出来**
|
|
22612
|
+
*
|
|
22613
|
+
* 一个 200 KB 的片段不该静默消失 —— 那与"我忘了写"在读数上同形。
|
|
22614
|
+
* ⇒ 返回 `oversize` 列表,由调用方在回执里点名(⛔ 静默丢)。
|
|
22615
|
+
*
|
|
22616
|
+
* ⚠️ 排序:按文件名,稳定(⛔ 按 mtime —— 那会让回执在两次调用间变化而无语义)。
|
|
22617
|
+
*/
|
|
22618
|
+
function listSnippets(cccRoot, urlOrHost) {
|
|
22619
|
+
const dir = snippetDir(cccRoot, urlOrHost);
|
|
22620
|
+
if (!dir || !existsSync(dir)) return {
|
|
22621
|
+
items: [],
|
|
22622
|
+
oversize: []
|
|
22623
|
+
};
|
|
22624
|
+
let names;
|
|
22625
|
+
try {
|
|
22626
|
+
names = readdirSync(dir);
|
|
22627
|
+
} catch {
|
|
22628
|
+
return {
|
|
22629
|
+
items: [],
|
|
22630
|
+
oversize: []
|
|
22631
|
+
};
|
|
22632
|
+
}
|
|
22633
|
+
const items = [];
|
|
22634
|
+
const oversize = [];
|
|
22635
|
+
for (const name of names.sort()) {
|
|
22636
|
+
if (!name.endsWith(".js")) continue;
|
|
22637
|
+
if (name.startsWith(".")) continue;
|
|
22638
|
+
const p = join(dir, name);
|
|
22639
|
+
let bytes;
|
|
22640
|
+
try {
|
|
22641
|
+
const st = statSync(p);
|
|
22642
|
+
if (!st.isFile()) continue;
|
|
22643
|
+
bytes = st.size;
|
|
22644
|
+
} catch {
|
|
22645
|
+
continue;
|
|
22646
|
+
}
|
|
22647
|
+
const rec = {
|
|
22648
|
+
name,
|
|
22649
|
+
path: p,
|
|
22650
|
+
bytes
|
|
22651
|
+
};
|
|
22652
|
+
if (bytes > 16384) oversize.push(rec);
|
|
22653
|
+
else items.push(rec);
|
|
22654
|
+
}
|
|
22655
|
+
return {
|
|
22656
|
+
items,
|
|
22657
|
+
oversize
|
|
22658
|
+
};
|
|
22659
|
+
}
|
|
22593
22660
|
/**
|
|
22594
22661
|
* 读该域名的说明书;未命中 ⇒ `null`(调用方**原样返回**回执,⛔ 不加任何噪声)。
|
|
22595
22662
|
*
|
|
@@ -22617,6 +22684,38 @@ function loadDomainSkill(cccRoot, urlOrHost) {
|
|
|
22617
22684
|
truncated
|
|
22618
22685
|
};
|
|
22619
22686
|
}
|
|
22687
|
+
/**
|
|
22688
|
+
* 片段的注入尾巴(设计 §改动 3)—— **只列清单,⛔ 不注入内容、⛔ 不执行**。
|
|
22689
|
+
*
|
|
22690
|
+
* ## 为什么只给清单而不给内容
|
|
22691
|
+
*
|
|
22692
|
+
* owner 裁决原话:「就是供 eval 用的 js 片段」。片段的价值是**可复用的认知**
|
|
22693
|
+
* (下次不用重新摸索选择器),而它的用法是:模型读了说明书 → 看到这里有几支片段 →
|
|
22694
|
+
* **自己决定**要不要 `eval` 其中一支。
|
|
22695
|
+
*
|
|
22696
|
+
* 🔴 若把内容也注进去,回执体量会失控(一支片段可达 16 KB),
|
|
22697
|
+
* 而且**等于替它做了"要不要用"的决定** —— 那不该由注入层替它做。
|
|
22698
|
+
*
|
|
22699
|
+
* ## 为什么超限的要单独点名
|
|
22700
|
+
*
|
|
22701
|
+
* 一支 200 KB 的片段若静默消失,与「我忘了写」在读数上同形。
|
|
22702
|
+
* ⇒ 明确告诉它"有这么个文件,但它太大没被采用",并给路径。
|
|
22703
|
+
*
|
|
22704
|
+
* @returns 追加文本;无片段 ⇒ **空串**(未命中零噪声,与说明书同一口径)
|
|
22705
|
+
*/
|
|
22706
|
+
function snippetTail(cccRoot, urlOrHost) {
|
|
22707
|
+
try {
|
|
22708
|
+
const { items, oversize } = listSnippets(cccRoot, urlOrHost);
|
|
22709
|
+
if (items.length === 0 && oversize.length === 0) return "";
|
|
22710
|
+
const lines = [`\n──── 本站可用片段(snippets/,供 eval 用)────`];
|
|
22711
|
+
for (const it of items) lines.push(` · ${it.name} ${(it.bytes / 1024).toFixed(1)} KB → ${it.path}`);
|
|
22712
|
+
for (const it of oversize) lines.push(` ⚠️ ${it.name} ${(it.bytes / 1024).toFixed(0)} KB —— 超过 ${SNIPPET_MAX_BYTES / 1024} KB 上限,**未采用**(⛔ 不是不存在)`);
|
|
22713
|
+
lines.push(" 用法:读一份说明书里对它的说明,再自己决定要不要 `browser_slot eval --js \"<片段内容>\"`。\n ⛔ 片段**不会自动执行** —— 它只是文本。");
|
|
22714
|
+
return lines.join("\n") + "\n";
|
|
22715
|
+
} catch {
|
|
22716
|
+
return "";
|
|
22717
|
+
}
|
|
22718
|
+
}
|
|
22620
22719
|
function visitLedgerPath(cccRoot) {
|
|
22621
22720
|
return join(browserRoot(cccRoot), VISIT_LEDGER_FILENAME);
|
|
22622
22721
|
}
|
|
@@ -22884,7 +22983,8 @@ function domainSkillTail(root, url, sessionId, slot) {
|
|
|
22884
22983
|
try {
|
|
22885
22984
|
recordVisit(root, url, sessionId, slot);
|
|
22886
22985
|
const hit = loadDomainSkill(root, url);
|
|
22887
|
-
|
|
22986
|
+
const snip = snippetTail(root, url);
|
|
22987
|
+
return (hit ? hit.text : "") + snip;
|
|
22888
22988
|
} catch {
|
|
22889
22989
|
return "";
|
|
22890
22990
|
}
|
|
@@ -22972,12 +23072,20 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
|
|
|
22972
23072
|
return `[browser_slot] targetId=${await slotOpen(root, n, sessionId, url)}` + domainSkillTail(root, url, sessionId, n);
|
|
22973
23073
|
}
|
|
22974
23074
|
case "goto": {
|
|
22975
|
-
const n =
|
|
23075
|
+
const n = normalizeSlotId(String(args.slot ?? ""));
|
|
22976
23076
|
const url = str(args.url);
|
|
22977
|
-
|
|
22978
|
-
const
|
|
22979
|
-
|
|
22980
|
-
|
|
23077
|
+
const target = str(args.target);
|
|
23078
|
+
const match = str(args.match);
|
|
23079
|
+
const missing = [];
|
|
23080
|
+
if (n === 0) missing.push("--slot <b1..b20>");
|
|
23081
|
+
if (!target && !match) missing.push("--target <targetId> 或 --match <URL/标题子串>(先跑 targets 看清有什么)");
|
|
23082
|
+
if (!url) missing.push("--url <目的地地址>");
|
|
23083
|
+
if (missing.length > 0) return `⛔ goto 缺少 ${missing.length} 个参数,一次列全:\n` + missing.map((m) => ` · ${m}`).join("\n") + `\n ⚠️ goto 与 open 形状不同:open 只要 --slot + --url;goto 还要指出**在哪个标签页**导航。`;
|
|
23084
|
+
const slotN = n;
|
|
23085
|
+
const destUrl = url;
|
|
23086
|
+
const tgt = target ?? await needTarget(root, slotN, sessionId, args);
|
|
23087
|
+
await slotGoto(root, slotN, sessionId, tgt, destUrl);
|
|
23088
|
+
return `[browser_slot] navigate ${tgt} → ${destUrl}` + domainSkillTail(root, destUrl, sessionId, slotN);
|
|
22981
23089
|
}
|
|
22982
23090
|
case "eval": {
|
|
22983
23091
|
const n = needSlot(args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.138.
|
|
3
|
+
"version": "1.138.3",
|
|
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": {
|