@shgroup/dsh-serenity-hooks 1.30.0 → 1.30.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.30.
|
|
3
|
+
"version": "1.30.3",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "宁静号 ACC harness(Native Cordis 插件):真实 DSH 工具 container_fs/logbook/dashboard/container_git/msm/praxis/handyman/localstore/container_admin/autopilot-trajectory + 拦截缝机械约束(safe-mode/路径守卫)+ 高级设定面板(双端口网关/账号管理)+ Skiff 认知子集角色(实验性)。适配 DSH 公开版(0.1.0-rc,deepseek-ai/deepseek-harness)。",
|
|
6
6
|
"engines": {
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { a as findSerenityRoot, c as matchBlacklist, d as readCccName$2, f as readHandymanConfig, i as findGitRoot, l as pathInside, m as resolveInside, n as SAFE_MODE_MARKER, o as isSafeModeOn, r as classifyPath, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS, u as readBlacklist } from "./ccc-CX48YNUL.js";
|
|
3
3
|
import { a as resolveRoleSystemPrompt, i as readSkiffRoles, l as systemPromptSource, r as isSkiffSessionId, s as roleToolWhitelist } from "./skiff-role-LW4tjF9L.js";
|
|
4
|
-
import { C as splitModel, E as skiffRoleFor, S as requireWhitelistedModel, T as writeProgress, _ as buildRoundPrompt, a as startSkiffDebugServer, b as newStopToken, c as askSkiff, d as skiffMsmGate, f as skiffSessionInfo, g as HANDYMAN_GUIDE, h as unregisterSkiffSession, l as createSkiffAgent, m as skiffTrajectoryEnabled, n as jscSafeJsonText, o as stopSkiffDebugServer, p as skiffSessionSnapshot, r as renderSkiffMarkdown, s as stripThink, t as discoverCccs, u as getSkiffAgent, v as handymanProgressPaths, w as writeFailedStatus, x as readProgress, y as listActiveHandymen } from "./skiff-debug-
|
|
4
|
+
import { C as splitModel, E as skiffRoleFor, S as requireWhitelistedModel, T as writeProgress, _ as buildRoundPrompt, a as startSkiffDebugServer, b as newStopToken, c as askSkiff, d as skiffMsmGate, f as skiffSessionInfo, g as HANDYMAN_GUIDE, h as unregisterSkiffSession, l as createSkiffAgent, m as skiffTrajectoryEnabled, n as jscSafeJsonText, o as stopSkiffDebugServer, p as skiffSessionSnapshot, r as renderSkiffMarkdown, s as stripThink, t as discoverCccs, u as getSkiffAgent, v as handymanProgressPaths, w as writeFailedStatus, x as readProgress, y as listActiveHandymen } from "./skiff-debug-CjV1g6T7.js";
|
|
5
5
|
import { a as readWeixinCredential, c as weixinInboundDir, d as LOCALSTORE_SCOPES, f as checkLocalstoreGitCompliance, h as runLocalStore, i as matchWeixinRoute, l as weixinSessionIdFor, m as readGitTrack, n as extractWeixinText, o as readWeixinSettings, p as localstorePath, r as hasVoiceItem, s as sanitizeFileName$1, t as extractWeixinMedia } from "./weixin-route-jA0qENOf.js";
|
|
6
6
|
import { C as useSession, S as summarize, _ as resolveSessionByTitle, a as archiveSessions, b as setActiveSessionInfo, c as extractSessionMdPathFromText, d as getActiveSessionInfo, f as healthCheck, g as readActiveSessionMd, h as qaCheck, i as SESSION_ACTIONS, l as findLatestActiveSessionMd, m as parseSessionContextFromEvents, n as readLastBound, o as closeSession, p as listSessions, r as DEFAULT_SESSION_SCOPE, s as createSession, t as appendBound, u as findSession, v as sessionEvents, x as showSession, y as sessionsRoot } from "./session-bound-p9oR9dj9.js";
|
|
7
7
|
import { n as registerSettingsSection, t as readSimpleSettings } from "./settings-section-BfVxgCZy.js";
|
|
@@ -603,6 +603,10 @@ function decideGuard(input) {
|
|
|
603
603
|
if (toolName === "skill") return { kind: "allow" };
|
|
604
604
|
const roleName = input.skiffSessionId ? skiffRoleFor(input.skiffSessionId) : null;
|
|
605
605
|
const role = roleName ? readSkiffRoles(root).get(roleName) : void 0;
|
|
606
|
+
if ((role?.msms ?? []).includes(toolName)) return {
|
|
607
|
+
deny: `"${toolName}" is a registered MSM, not a direct tool in this role — call it through the msm tool: msm("${toolName}", ["<args>"]) (pass "--help" or inspect=true for usage)`,
|
|
608
|
+
kind: "deny"
|
|
609
|
+
};
|
|
606
610
|
if (!roleToolWhitelist(role).has(toolName)) return {
|
|
607
611
|
deny: "tool not allowed in this skiff role",
|
|
608
612
|
kind: "deny"
|
|
@@ -6067,7 +6071,7 @@ function registerStatusApi(ctx, opts = {}) {
|
|
|
6067
6071
|
workspace: url.searchParams.get("workspace") ?? void 0
|
|
6068
6072
|
});
|
|
6069
6073
|
const root = findSerenityRoot(workspace) ?? "";
|
|
6070
|
-
const { discoverCccs } = await import("./skiff-debug-
|
|
6074
|
+
const { discoverCccs } = await import("./skiff-debug-CjV1g6T7.js").then((n) => n.i);
|
|
6071
6075
|
sendJson$1(res, 200, { cccs: await discoverCccs(ctx, root) });
|
|
6072
6076
|
} catch (err) {
|
|
6073
6077
|
sendJson$1(res, 400, { error: err.message ?? String(err) });
|
package/lib/skiff-core.d.ts
CHANGED
|
@@ -27,6 +27,29 @@ export declare function skiffSessionSnapshot(): ReadonlyMap<string, {
|
|
|
27
27
|
role: string;
|
|
28
28
|
ccc: string;
|
|
29
29
|
}>;
|
|
30
|
+
/**
|
|
31
|
+
* 系统提示词中的工作台指引段(agent 上下文,用户对话面不可见)。
|
|
32
|
+
* SESSION = 工作台——skiff 与主舱同一套机制:write/edit 记进度,logbook rebuild 续接。
|
|
33
|
+
*/
|
|
34
|
+
export declare function workspaceTrajectoryLine(mdPath: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* 确保启用 session 能力的 skiff 会话拥有**专属 SESSION**(工作台):
|
|
37
|
+
* 懒绑定 + 幂等(per skiff 会话 scope 隔离——微信多用户各自独立,永不共享同一份)。
|
|
38
|
+
*
|
|
39
|
+
* 判定链:
|
|
40
|
+
* ① 角色未启用 session 能力(trajectory.session !== true)→ null(现状零变化)
|
|
41
|
+
* ② 会话日志已有**本机制自动创建**的 bound(note 前缀 auto-created)→ 恢复(重启/续接记得)
|
|
42
|
+
* ③ 无 → 自动创建专属 SESSION(createSession desc=`<role> skiff`——编号自动递增,用户不关心是谁)
|
|
43
|
+
*
|
|
44
|
+
* @returns 绑定后的 SESSION.md 绝对路径(供提示词注入);不适用/失败 → null
|
|
45
|
+
*/
|
|
46
|
+
export declare function ensureSkiffSession(root: string, agent: Agent, roleName: string, role: SkiffRoleConfig): string | null;
|
|
47
|
+
/** 当前 scope 是否已激活(幂等判定:getActiveSessionInfo 命中同 dirName)——测试用 */
|
|
48
|
+
export declare function skiffSessionActiveFor(sessionId: string): {
|
|
49
|
+
sessionId: string;
|
|
50
|
+
dirName: string;
|
|
51
|
+
mdPath: string;
|
|
52
|
+
} | null;
|
|
30
53
|
export interface SkiffAgentRef {
|
|
31
54
|
handle: AgentHandle;
|
|
32
55
|
agent: Agent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { a as findSerenityRoot, f as readHandymanConfig } from "./ccc-CX48YNUL.js";
|
|
3
3
|
import { a as resolveRoleSystemPrompt, i as readSkiffRoles, n as buildSkiffBasePrompt, o as roleMsmWhitelist, r as isSkiffSessionId, u as trajectorySubset } from "./skiff-role-LW4tjF9L.js";
|
|
4
|
+
import { b as setActiveSessionInfo, n as readLastBound, s as createSession, t as appendBound } from "./session-bound-p9oR9dj9.js";
|
|
4
5
|
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
5
6
|
import { basename, join } from "node:path";
|
|
6
7
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
@@ -244,6 +245,60 @@ function skiffSessionSnapshot() {
|
|
|
244
245
|
});
|
|
245
246
|
return out;
|
|
246
247
|
}
|
|
248
|
+
/** 自动创建的 bound 标记(readLastBound 恢复判定——只恢复本机制建的;手工 use 的旧 bound 不认) */
|
|
249
|
+
const AUTO_BOUND_NOTE_PREFIX = "auto-created for skiff role";
|
|
250
|
+
/**
|
|
251
|
+
* 系统提示词中的工作台指引段(agent 上下文,用户对话面不可见)。
|
|
252
|
+
* SESSION = 工作台——skiff 与主舱同一套机制:write/edit 记进度,logbook rebuild 续接。
|
|
253
|
+
*/
|
|
254
|
+
function workspaceTrajectoryLine(mdPath) {
|
|
255
|
+
return `Your trajectory workspace (auto-assigned SESSION):
|
|
256
|
+
SESSION.md: ${mdPath}\n Record progress/decisions here with write/edit; logbook rebuild resumes from this SESSION.`;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* 确保启用 session 能力的 skiff 会话拥有**专属 SESSION**(工作台):
|
|
260
|
+
* 懒绑定 + 幂等(per skiff 会话 scope 隔离——微信多用户各自独立,永不共享同一份)。
|
|
261
|
+
*
|
|
262
|
+
* 判定链:
|
|
263
|
+
* ① 角色未启用 session 能力(trajectory.session !== true)→ null(现状零变化)
|
|
264
|
+
* ② 会话日志已有**本机制自动创建**的 bound(note 前缀 auto-created)→ 恢复(重启/续接记得)
|
|
265
|
+
* ③ 无 → 自动创建专属 SESSION(createSession desc=`<role> skiff`——编号自动递增,用户不关心是谁)
|
|
266
|
+
*
|
|
267
|
+
* @returns 绑定后的 SESSION.md 绝对路径(供提示词注入);不适用/失败 → null
|
|
268
|
+
*/
|
|
269
|
+
function ensureSkiffSession(root, agent, roleName, role) {
|
|
270
|
+
if (!trajectorySubset(role).session) return null;
|
|
271
|
+
const session = agent.session;
|
|
272
|
+
const scope = String(agent.session.id ?? agent.id);
|
|
273
|
+
const lastBound = session ? readLastBound(session) : null;
|
|
274
|
+
if (lastBound && lastBound.note?.startsWith(AUTO_BOUND_NOTE_PREFIX) && existsSync(lastBound.mdPath)) {
|
|
275
|
+
setActiveSessionInfo(scope, {
|
|
276
|
+
sessionId: lastBound.sessionId ?? "",
|
|
277
|
+
dirName: lastBound.dirName,
|
|
278
|
+
mdPath: lastBound.mdPath
|
|
279
|
+
});
|
|
280
|
+
return lastBound.mdPath;
|
|
281
|
+
}
|
|
282
|
+
const desc = `${roleName} skiff`;
|
|
283
|
+
const created = createSession({
|
|
284
|
+
root,
|
|
285
|
+
desc,
|
|
286
|
+
dryRun: false
|
|
287
|
+
});
|
|
288
|
+
const mdPath = join(created.sessionPath, "SESSION.md");
|
|
289
|
+
setActiveSessionInfo(scope, {
|
|
290
|
+
sessionId: created.sessionId,
|
|
291
|
+
dirName: created.dirName,
|
|
292
|
+
mdPath
|
|
293
|
+
});
|
|
294
|
+
appendBound(session, "create", {
|
|
295
|
+
dirName: created.dirName,
|
|
296
|
+
mdPath,
|
|
297
|
+
sessionId: created.sessionId,
|
|
298
|
+
note: `${AUTO_BOUND_NOTE_PREFIX} ${roleName}`
|
|
299
|
+
});
|
|
300
|
+
return mdPath;
|
|
301
|
+
}
|
|
247
302
|
/** Skiff agent 挂载的 DSH preset(v1.25.3 修复:read/grep/glob 等平台工具由 preset 决定工具面;
|
|
248
303
|
* handyman 经 composeFrom 继承父、skiff 无父上下文——直接挂 DSH 默认 standard preset;
|
|
249
304
|
* guard 角色白名单再按角色过滤可见/可用面——白名单外工具仍 deny) */
|
|
@@ -278,11 +333,21 @@ async function createSkiffAgent(ctx, root, roleName, role, defaultModel, session
|
|
|
278
333
|
} catch (err) {
|
|
279
334
|
console.warn(`[serenity-hooks] skiff 角色 "${roleName}" 系统提示词解析失败(回退仅基础段): ${String(err?.message ?? err)}`);
|
|
280
335
|
}
|
|
336
|
+
let workspaceMdPath = null;
|
|
337
|
+
try {
|
|
338
|
+
workspaceMdPath = ensureSkiffSession(root, agent, roleName, role);
|
|
339
|
+
} catch (err) {
|
|
340
|
+
console.warn(`[serenity-hooks] skiff 角色 "${roleName}" 专属 SESSION 处理失败(不影响 agent 创建): ${String(err?.message ?? err)}`);
|
|
341
|
+
}
|
|
281
342
|
try {
|
|
282
343
|
agent.ctx.systemPrompt.section({
|
|
283
344
|
name: "serenity-skiff",
|
|
284
345
|
order: -60,
|
|
285
|
-
text: () => [
|
|
346
|
+
text: () => [
|
|
347
|
+
buildSkiffBasePrompt(roleName, role),
|
|
348
|
+
workspaceMdPath ? workspaceTrajectoryLine(workspaceMdPath) : "",
|
|
349
|
+
cccPrompt
|
|
350
|
+
].filter(Boolean).join("\n")
|
|
286
351
|
});
|
|
287
352
|
} catch (err) {
|
|
288
353
|
console.warn(`[serenity-hooks] skiff 系统提示词注册失败: ${String(err?.message ?? err)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.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": {
|