@morlay/dsh-session-mode 0.0.14 → 0.0.16
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/README.md +20 -7
- package/dist/client.cjs +4576 -3901
- package/dist/client.d.cts +41 -43
- package/dist/client.d.mts +41 -43
- package/dist/client.mjs +952 -1233
- package/dist/index.cjs +748 -70
- package/dist/index.d.mts +26 -55
- package/dist/index.mjs +742 -65
- package/dist/mode-config-CiQfAy4G.mjs +99 -0
- package/dist/mode-config-DOQ1VjcM.cjs +225 -0
- package/dist/rows-BT6Fpq-E.cjs +99 -0
- package/dist/rows-DnHpp-Ak.mjs +82 -0
- package/dist/rows.cjs +3 -86
- package/dist/rows.d.mts +31 -1
- package/dist/rows.mjs +1 -86
- package/dist/shared-R2j0SuWy.d.mts +118 -0
- package/package.json +70 -56
- package/src/client/SessionModePanel.tsx +803 -0
- package/src/client/api.ts +125 -1
- package/src/client/hints.ts +41 -0
- package/src/client/index.ts +71 -55
- package/src/client/locales.ts +80 -0
- package/src/index.ts +581 -20
- package/src/mode-config.ts +104 -0
- package/src/mode-sources.ts +4 -4
- package/src/mode-store.ts +53 -0
- package/src/modes.ts +23 -28
- package/src/per-agent.ts +53 -0
- package/src/ptc-describe.ts +97 -0
- package/src/ptc-sdk.ts +90 -0
- package/src/rows.ts +4 -8
- package/src/scope.ts +369 -71
- package/src/session-mode-store.ts +20 -0
- package/src/shared.ts +128 -3
- package/src/system-remainder.ts +39 -0
- package/src/tool-groups.ts +19 -0
- package/dist/shared-DO1nZbJ0.cjs +0 -64
- package/dist/shared-vjlwxiMt.mjs +0 -4
- package/src/client/BundleConfigPage.tsx +0 -631
- package/src/client/bundle-config.ts +0 -701
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { groupByKey, groupOfTool, groupTitleOf } from "@morlay/dsh-tool-guidance/groups";
|
|
2
|
+
// src/shared.ts
|
|
3
|
+
const SESSION_MODE_PATH = "/api/morlay/v1/session-mode";
|
|
4
|
+
const POLICY_NAMES = [
|
|
5
|
+
"fs/write-intent",
|
|
6
|
+
"fs/edit-intent",
|
|
7
|
+
"fs/delete-intent"
|
|
8
|
+
];
|
|
9
|
+
const PROTECTED_TOOLS = /* @__PURE__ */ new Set(["run_code", "describe_tool"]);
|
|
10
|
+
function isProtectedTool(name) {
|
|
11
|
+
return PROTECTED_TOOLS.has(name);
|
|
12
|
+
}
|
|
13
|
+
function toolGroupOf(name) {
|
|
14
|
+
const known = groupOfTool(name);
|
|
15
|
+
if (known !== void 0) return known;
|
|
16
|
+
if (name.startsWith("mcp__")) {
|
|
17
|
+
const rest = name.slice(5);
|
|
18
|
+
const separator = rest.indexOf("__");
|
|
19
|
+
if (separator > 0) return `mcp:${rest.slice(0, separator)}`;
|
|
20
|
+
}
|
|
21
|
+
if (name.startsWith("tool_group_")) return "onDemand";
|
|
22
|
+
return "other";
|
|
23
|
+
}
|
|
24
|
+
function isResidentToolGroup(group) {
|
|
25
|
+
if (group === "onDemand" || group === "other") return true;
|
|
26
|
+
if (group.startsWith("mcp:")) return false;
|
|
27
|
+
try {
|
|
28
|
+
return groupByKey(group).injection === "init";
|
|
29
|
+
} catch {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function toolGroupLabel(group) {
|
|
34
|
+
if (group.startsWith("mcp:")) return `MCP · ${group.slice(4)}`;
|
|
35
|
+
return groupTitleOf(group) ?? (group === "onDemand" ? "按需工具" : "其它");
|
|
36
|
+
}
|
|
37
|
+
function groupRef(group) {
|
|
38
|
+
return group.startsWith("mcp:") ? group : `group:${group}`;
|
|
39
|
+
}
|
|
40
|
+
function refGroup(ref) {
|
|
41
|
+
return ref.startsWith("group:") ? ref.slice(6) : ref;
|
|
42
|
+
}
|
|
43
|
+
function deniedByList(deny, id) {
|
|
44
|
+
const group = toolGroupOf(id);
|
|
45
|
+
return deny.some((ref) => ref === id || (ref.startsWith("group:") || ref.startsWith("mcp:")) && refGroup(ref) === group);
|
|
46
|
+
}
|
|
47
|
+
const POLICY_DESCRIPTIONS = {
|
|
48
|
+
"fs/write-intent": "文件写入前的意图检查(CAS 安全网)。",
|
|
49
|
+
"fs/edit-intent": "文件编辑前的意图检查(先读后改那条规则)。",
|
|
50
|
+
"fs/delete-intent": "文件删除前的意图检查。"
|
|
51
|
+
};
|
|
52
|
+
// src/mode-config.ts
|
|
53
|
+
function resolveModeConfig(config, session) {
|
|
54
|
+
return structuredClone(session ?? config);
|
|
55
|
+
}
|
|
56
|
+
function asModeConfig(mode, skills) {
|
|
57
|
+
return {
|
|
58
|
+
...mode,
|
|
59
|
+
skills
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function applyDraft(config, draft, defaults) {
|
|
63
|
+
const view = { ...structuredClone(config) };
|
|
64
|
+
for (const [kind, allowKey, denyKey] of [
|
|
65
|
+
[
|
|
66
|
+
"tools",
|
|
67
|
+
"allowTools",
|
|
68
|
+
"denyTools"
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
"skills",
|
|
72
|
+
"allowSkills",
|
|
73
|
+
"denySkills"
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"policies",
|
|
77
|
+
"allowPolicies",
|
|
78
|
+
"denyPolicies"
|
|
79
|
+
]
|
|
80
|
+
]) {
|
|
81
|
+
const allow = new Set(view[allowKey]);
|
|
82
|
+
const deny = new Set(view[denyKey]);
|
|
83
|
+
for (const [id, value] of Object.entries(draft.lists?.[kind] ?? {})) if (value === "deny") deny.add(id);
|
|
84
|
+
else if (value === "allow") {
|
|
85
|
+
deny.delete(id);
|
|
86
|
+
if (allow.size > 0) allow.add(id);
|
|
87
|
+
} else {
|
|
88
|
+
allow.delete(id);
|
|
89
|
+
deny.delete(id);
|
|
90
|
+
}
|
|
91
|
+
view[allowKey] = [...allow];
|
|
92
|
+
view[denyKey] = [...deny];
|
|
93
|
+
}
|
|
94
|
+
if (draft.persona !== void 0 && draft.persona !== null) view["persona"] = draft.persona;
|
|
95
|
+
for (const [key, value] of Object.entries(draft.switches ?? {})) if (value !== null) view[key] = value;
|
|
96
|
+
else if (defaults !== void 0) view[key] = defaults[key];
|
|
97
|
+
return view;
|
|
98
|
+
}
|
|
99
|
+
export { POLICY_NAMES as a, groupRef as c, refGroup as d, toolGroupLabel as f, POLICY_DESCRIPTIONS as i, isProtectedTool as l, asModeConfig as n, SESSION_MODE_PATH as o, toolGroupOf as p, resolveModeConfig as r, deniedByList as s, applyDraft as t, isResidentToolGroup as u };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
+
key = keys[i];
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
let _morlay_dsh_tool_guidance_groups = require("@morlay/dsh-tool-guidance/groups");
|
|
33
|
+
// src/shared.ts
|
|
34
|
+
const SESSION_MODE_PATH = "/api/morlay/v1/session-mode";
|
|
35
|
+
const POLICY_NAMES = [
|
|
36
|
+
"fs/write-intent",
|
|
37
|
+
"fs/edit-intent",
|
|
38
|
+
"fs/delete-intent"
|
|
39
|
+
];
|
|
40
|
+
const PROTECTED_TOOLS = /* @__PURE__ */ new Set(["run_code", "describe_tool"]);
|
|
41
|
+
function isProtectedTool(name) {
|
|
42
|
+
return PROTECTED_TOOLS.has(name);
|
|
43
|
+
}
|
|
44
|
+
function toolGroupOf(name) {
|
|
45
|
+
const known = (0, _morlay_dsh_tool_guidance_groups.groupOfTool)(name);
|
|
46
|
+
if (known !== void 0) return known;
|
|
47
|
+
if (name.startsWith("mcp__")) {
|
|
48
|
+
const rest = name.slice(5);
|
|
49
|
+
const separator = rest.indexOf("__");
|
|
50
|
+
if (separator > 0) return `mcp:${rest.slice(0, separator)}`;
|
|
51
|
+
}
|
|
52
|
+
if (name.startsWith("tool_group_")) return "onDemand";
|
|
53
|
+
return "other";
|
|
54
|
+
}
|
|
55
|
+
function isResidentToolGroup(group) {
|
|
56
|
+
if (group === "onDemand" || group === "other") return true;
|
|
57
|
+
if (group.startsWith("mcp:")) return false;
|
|
58
|
+
try {
|
|
59
|
+
return (0, _morlay_dsh_tool_guidance_groups.groupByKey)(group).injection === "init";
|
|
60
|
+
} catch {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function toolGroupLabel(group) {
|
|
65
|
+
if (group.startsWith("mcp:")) return `MCP · ${group.slice(4)}`;
|
|
66
|
+
return (0, _morlay_dsh_tool_guidance_groups.groupTitleOf)(group) ?? (group === "onDemand" ? "按需工具" : "其它");
|
|
67
|
+
}
|
|
68
|
+
function groupRef(group) {
|
|
69
|
+
return group.startsWith("mcp:") ? group : `group:${group}`;
|
|
70
|
+
}
|
|
71
|
+
function refGroup(ref) {
|
|
72
|
+
return ref.startsWith("group:") ? ref.slice(6) : ref;
|
|
73
|
+
}
|
|
74
|
+
function deniedByList(deny, id) {
|
|
75
|
+
const group = toolGroupOf(id);
|
|
76
|
+
return deny.some((ref) => ref === id || (ref.startsWith("group:") || ref.startsWith("mcp:")) && refGroup(ref) === group);
|
|
77
|
+
}
|
|
78
|
+
const POLICY_DESCRIPTIONS = {
|
|
79
|
+
"fs/write-intent": "文件写入前的意图检查(CAS 安全网)。",
|
|
80
|
+
"fs/edit-intent": "文件编辑前的意图检查(先读后改那条规则)。",
|
|
81
|
+
"fs/delete-intent": "文件删除前的意图检查。"
|
|
82
|
+
};
|
|
83
|
+
// src/mode-config.ts
|
|
84
|
+
function resolveModeConfig(config, session) {
|
|
85
|
+
return structuredClone(session ?? config);
|
|
86
|
+
}
|
|
87
|
+
function asModeConfig(mode, skills) {
|
|
88
|
+
return {
|
|
89
|
+
...mode,
|
|
90
|
+
skills
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function applyDraft(config, draft, defaults) {
|
|
94
|
+
const view = { ...structuredClone(config) };
|
|
95
|
+
for (const [kind, allowKey, denyKey] of [
|
|
96
|
+
[
|
|
97
|
+
"tools",
|
|
98
|
+
"allowTools",
|
|
99
|
+
"denyTools"
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
"skills",
|
|
103
|
+
"allowSkills",
|
|
104
|
+
"denySkills"
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"policies",
|
|
108
|
+
"allowPolicies",
|
|
109
|
+
"denyPolicies"
|
|
110
|
+
]
|
|
111
|
+
]) {
|
|
112
|
+
const allow = new Set(view[allowKey]);
|
|
113
|
+
const deny = new Set(view[denyKey]);
|
|
114
|
+
for (const [id, value] of Object.entries(draft.lists?.[kind] ?? {})) if (value === "deny") deny.add(id);
|
|
115
|
+
else if (value === "allow") {
|
|
116
|
+
deny.delete(id);
|
|
117
|
+
if (allow.size > 0) allow.add(id);
|
|
118
|
+
} else {
|
|
119
|
+
allow.delete(id);
|
|
120
|
+
deny.delete(id);
|
|
121
|
+
}
|
|
122
|
+
view[allowKey] = [...allow];
|
|
123
|
+
view[denyKey] = [...deny];
|
|
124
|
+
}
|
|
125
|
+
if (draft.persona !== void 0 && draft.persona !== null) view["persona"] = draft.persona;
|
|
126
|
+
for (const [key, value] of Object.entries(draft.switches ?? {})) if (value !== null) view[key] = value;
|
|
127
|
+
else if (defaults !== void 0) view[key] = defaults[key];
|
|
128
|
+
return view;
|
|
129
|
+
}
|
|
130
|
+
Object.defineProperty(exports, "POLICY_DESCRIPTIONS", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function() {
|
|
133
|
+
return POLICY_DESCRIPTIONS;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(exports, "POLICY_NAMES", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
get: function() {
|
|
139
|
+
return POLICY_NAMES;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(exports, "SESSION_MODE_PATH", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function() {
|
|
145
|
+
return SESSION_MODE_PATH;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(exports, "__exportAll", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function() {
|
|
151
|
+
return __exportAll;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(exports, "__reExport", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
get: function() {
|
|
157
|
+
return __reExport;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(exports, "__toESM", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function() {
|
|
163
|
+
return __toESM;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, "applyDraft", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function() {
|
|
169
|
+
return applyDraft;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(exports, "asModeConfig", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function() {
|
|
175
|
+
return asModeConfig;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(exports, "deniedByList", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
get: function() {
|
|
181
|
+
return deniedByList;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(exports, "groupRef", {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function() {
|
|
187
|
+
return groupRef;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
Object.defineProperty(exports, "isProtectedTool", {
|
|
191
|
+
enumerable: true,
|
|
192
|
+
get: function() {
|
|
193
|
+
return isProtectedTool;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
Object.defineProperty(exports, "isResidentToolGroup", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: function() {
|
|
199
|
+
return isResidentToolGroup;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
Object.defineProperty(exports, "refGroup", {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
get: function() {
|
|
205
|
+
return refGroup;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(exports, "resolveModeConfig", {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function() {
|
|
211
|
+
return resolveModeConfig;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
Object.defineProperty(exports, "toolGroupLabel", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
get: function() {
|
|
217
|
+
return toolGroupLabel;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(exports, "toolGroupOf", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function() {
|
|
223
|
+
return toolGroupOf;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// src/mode-sources.ts
|
|
2
|
+
const CODING_PERSONA = { prefix: [
|
|
3
|
+
"你是一个经验丰富的编程专家,YAGNI 是你的编程哲学,PDCA 是你的行为规范。",
|
|
4
|
+
"全程 MUST 用中文(专有名词除外),包括但不限于思考,回答,工具描述,subagent 提示词;思考 NEVER 陷入重复循环,一旦循环立即退出;思考 SHOULD 聚焦需求理解与方案设计,不预演具体代码实现,正确性由验证环节确认。",
|
|
5
|
+
"单轮次内 MUST 完成明确的任务,任务未完成 NEVER 停下,除非有明确分歧点需要停下询问用户来做决断"
|
|
6
|
+
].join("\n") };
|
|
7
|
+
const CHAT_PERSONA = { prefix: "你是一个助手。全程用中文(专有名词除外),包括但不限于思考,回答,工具描述;思考不要陷入重复循环,一旦循环立即退出。" };
|
|
8
|
+
const NOOP_MODE_ID = "noop";
|
|
9
|
+
const DEFAULT_MODE = "coding";
|
|
10
|
+
const MODE_SOURCES = [
|
|
11
|
+
{
|
|
12
|
+
id: "coding",
|
|
13
|
+
name: "编码模式",
|
|
14
|
+
description: "功能完整的编码 Agent:文件、Shell、检索、联网等工具常驻,其余用法说明按需加载。",
|
|
15
|
+
persona: CODING_PERSONA,
|
|
16
|
+
role: ["main", "subagent"],
|
|
17
|
+
denyTools: ["load_workspace_dependencies", "plugin_manager"],
|
|
18
|
+
denySkills: [
|
|
19
|
+
"office-docx",
|
|
20
|
+
"office-pptx",
|
|
21
|
+
"office-xlsx"
|
|
22
|
+
],
|
|
23
|
+
denyPolicies: ["fs/edit-intent", "fs/write-intent"]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "chat",
|
|
27
|
+
name: "对话模式",
|
|
28
|
+
description: "只做对话:提问与联网(搜索、抓取)三件工具,不注入系统提示词、工作区指令与技能目录。",
|
|
29
|
+
persona: CHAT_PERSONA,
|
|
30
|
+
role: ["main"],
|
|
31
|
+
allowTools: [
|
|
32
|
+
"ask_user_question",
|
|
33
|
+
"web_search",
|
|
34
|
+
"web_fetch"
|
|
35
|
+
],
|
|
36
|
+
instructions: false,
|
|
37
|
+
runtimeContext: false
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: NOOP_MODE_ID,
|
|
41
|
+
name: "原样模式",
|
|
42
|
+
description: "与上游一致:不加人格提示词、不收窄工具与技能、policy 规则全开、官方注入面照旧。",
|
|
43
|
+
role: ["main", "subagent"]
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
// src/rows.ts
|
|
47
|
+
function list(values) {
|
|
48
|
+
return values === void 0 || values.length === 0 ? void 0 : [...values];
|
|
49
|
+
}
|
|
50
|
+
function modeConfig(source) {
|
|
51
|
+
const allowTools = list(source.allowTools);
|
|
52
|
+
const denyTools = list(source.denyTools);
|
|
53
|
+
const allowSkills = list(source.allowSkills);
|
|
54
|
+
const denySkills = list(source.denySkills);
|
|
55
|
+
const allowPolicies = list(source.allowPolicies);
|
|
56
|
+
const denyPolicies = list(source.denyPolicies);
|
|
57
|
+
return {
|
|
58
|
+
name: source.name,
|
|
59
|
+
description: source.description,
|
|
60
|
+
...source.role === void 0 ? {} : { role: [...source.role] },
|
|
61
|
+
...source.persona === void 0 ? {} : { persona: { ...source.persona } },
|
|
62
|
+
...allowTools === void 0 ? {} : { allowTools },
|
|
63
|
+
...denyTools === void 0 ? {} : { denyTools },
|
|
64
|
+
...allowSkills === void 0 ? {} : { allowSkills },
|
|
65
|
+
...denySkills === void 0 ? {} : { denySkills },
|
|
66
|
+
...allowPolicies === void 0 ? {} : { allowPolicies },
|
|
67
|
+
...denyPolicies === void 0 ? {} : { denyPolicies },
|
|
68
|
+
...source.instructions === void 0 ? {} : { instructions: source.instructions },
|
|
69
|
+
...source.skills === void 0 ? {} : { skills: source.skills },
|
|
70
|
+
...source.dropSections === void 0 ? {} : { dropSections: [...source.dropSections] },
|
|
71
|
+
...source.runtimeContext === void 0 ? {} : { runtimeContext: source.runtimeContext },
|
|
72
|
+
...source.defaultModel === void 0 ? {} : { defaultModel: { ...source.defaultModel } }
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function sessionModeRows() {
|
|
76
|
+
return [{ insert: [{
|
|
77
|
+
id: "session-mode",
|
|
78
|
+
name: "@morlay/dsh-session-mode",
|
|
79
|
+
config: { default: DEFAULT_MODE }
|
|
80
|
+
}] }];
|
|
81
|
+
}
|
|
82
|
+
Object.defineProperty(exports, "MODE_SOURCES", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function() {
|
|
85
|
+
return MODE_SOURCES;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "modeConfig", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function() {
|
|
91
|
+
return modeConfig;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, "sessionModeRows", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function() {
|
|
97
|
+
return sessionModeRows;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/mode-sources.ts
|
|
2
|
+
const CODING_PERSONA = { prefix: [
|
|
3
|
+
"你是一个经验丰富的编程专家,YAGNI 是你的编程哲学,PDCA 是你的行为规范。",
|
|
4
|
+
"全程 MUST 用中文(专有名词除外),包括但不限于思考,回答,工具描述,subagent 提示词;思考 NEVER 陷入重复循环,一旦循环立即退出;思考 SHOULD 聚焦需求理解与方案设计,不预演具体代码实现,正确性由验证环节确认。",
|
|
5
|
+
"单轮次内 MUST 完成明确的任务,任务未完成 NEVER 停下,除非有明确分歧点需要停下询问用户来做决断"
|
|
6
|
+
].join("\n") };
|
|
7
|
+
const CHAT_PERSONA = { prefix: "你是一个助手。全程用中文(专有名词除外),包括但不限于思考,回答,工具描述;思考不要陷入重复循环,一旦循环立即退出。" };
|
|
8
|
+
const NOOP_MODE_ID = "noop";
|
|
9
|
+
const DEFAULT_MODE = "coding";
|
|
10
|
+
const MODE_SOURCES = [
|
|
11
|
+
{
|
|
12
|
+
id: "coding",
|
|
13
|
+
name: "编码模式",
|
|
14
|
+
description: "功能完整的编码 Agent:文件、Shell、检索、联网等工具常驻,其余用法说明按需加载。",
|
|
15
|
+
persona: CODING_PERSONA,
|
|
16
|
+
role: ["main", "subagent"],
|
|
17
|
+
denyTools: ["load_workspace_dependencies", "plugin_manager"],
|
|
18
|
+
denySkills: [
|
|
19
|
+
"office-docx",
|
|
20
|
+
"office-pptx",
|
|
21
|
+
"office-xlsx"
|
|
22
|
+
],
|
|
23
|
+
denyPolicies: ["fs/edit-intent", "fs/write-intent"]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "chat",
|
|
27
|
+
name: "对话模式",
|
|
28
|
+
description: "只做对话:提问与联网(搜索、抓取)三件工具,不注入系统提示词、工作区指令与技能目录。",
|
|
29
|
+
persona: CHAT_PERSONA,
|
|
30
|
+
role: ["main"],
|
|
31
|
+
allowTools: [
|
|
32
|
+
"ask_user_question",
|
|
33
|
+
"web_search",
|
|
34
|
+
"web_fetch"
|
|
35
|
+
],
|
|
36
|
+
instructions: false,
|
|
37
|
+
runtimeContext: false
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: NOOP_MODE_ID,
|
|
41
|
+
name: "原样模式",
|
|
42
|
+
description: "与上游一致:不加人格提示词、不收窄工具与技能、policy 规则全开、官方注入面照旧。",
|
|
43
|
+
role: ["main", "subagent"]
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
// src/rows.ts
|
|
47
|
+
function list(values) {
|
|
48
|
+
return values === void 0 || values.length === 0 ? void 0 : [...values];
|
|
49
|
+
}
|
|
50
|
+
function modeConfig(source) {
|
|
51
|
+
const allowTools = list(source.allowTools);
|
|
52
|
+
const denyTools = list(source.denyTools);
|
|
53
|
+
const allowSkills = list(source.allowSkills);
|
|
54
|
+
const denySkills = list(source.denySkills);
|
|
55
|
+
const allowPolicies = list(source.allowPolicies);
|
|
56
|
+
const denyPolicies = list(source.denyPolicies);
|
|
57
|
+
return {
|
|
58
|
+
name: source.name,
|
|
59
|
+
description: source.description,
|
|
60
|
+
...source.role === void 0 ? {} : { role: [...source.role] },
|
|
61
|
+
...source.persona === void 0 ? {} : { persona: { ...source.persona } },
|
|
62
|
+
...allowTools === void 0 ? {} : { allowTools },
|
|
63
|
+
...denyTools === void 0 ? {} : { denyTools },
|
|
64
|
+
...allowSkills === void 0 ? {} : { allowSkills },
|
|
65
|
+
...denySkills === void 0 ? {} : { denySkills },
|
|
66
|
+
...allowPolicies === void 0 ? {} : { allowPolicies },
|
|
67
|
+
...denyPolicies === void 0 ? {} : { denyPolicies },
|
|
68
|
+
...source.instructions === void 0 ? {} : { instructions: source.instructions },
|
|
69
|
+
...source.skills === void 0 ? {} : { skills: source.skills },
|
|
70
|
+
...source.dropSections === void 0 ? {} : { dropSections: [...source.dropSections] },
|
|
71
|
+
...source.runtimeContext === void 0 ? {} : { runtimeContext: source.runtimeContext },
|
|
72
|
+
...source.defaultModel === void 0 ? {} : { defaultModel: { ...source.defaultModel } }
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function sessionModeRows() {
|
|
76
|
+
return [{ insert: [{
|
|
77
|
+
id: "session-mode",
|
|
78
|
+
name: "@morlay/dsh-session-mode",
|
|
79
|
+
config: { default: DEFAULT_MODE }
|
|
80
|
+
}] }];
|
|
81
|
+
}
|
|
82
|
+
export { sessionModeRows as n, MODE_SOURCES as r, modeConfig as t };
|
package/dist/rows.cjs
CHANGED
|
@@ -1,87 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"全程 MUST 用中文(专有名词除外),包括但不限于思考,回答,工具描述,subagent 提示词;思考 NEVER 陷入重复循环,一旦循环立即退出;思考 SHOULD 聚焦需求理解与方案设计,不预演具体代码实现,正确性由验证环节确认。",
|
|
6
|
-
"单轮次内 MUST 完成明确的任务,任务未完成 NEVER 停下,除非有明确分歧点需要停下询问用户来做决断"
|
|
7
|
-
].join("\n") };
|
|
8
|
-
const CHAT_PERSONA = { prefix: "你是一个助手。全程用中文(专有名词除外),包括但不限于思考,回答,工具描述;思考不要陷入重复循环,一旦循环立即退出。" };
|
|
9
|
-
const NOOP_MODE_ID = "noop";
|
|
10
|
-
const DEFAULT_MODE = "coding";
|
|
11
|
-
const MODE_SOURCES = [
|
|
12
|
-
{
|
|
13
|
-
id: "coding",
|
|
14
|
-
name: "编码模式",
|
|
15
|
-
description: "功能完整的编码 Agent:文件、Shell、检索、联网等工具常驻,其余用法说明按需加载。",
|
|
16
|
-
persona: CODING_PERSONA,
|
|
17
|
-
role: ["main", "subagent"],
|
|
18
|
-
denyTools: ["load_workspace_dependencies", "plugin_manager"],
|
|
19
|
-
denySkills: [
|
|
20
|
-
"office-docx",
|
|
21
|
-
"office-pptx",
|
|
22
|
-
"office-xlsx"
|
|
23
|
-
],
|
|
24
|
-
denyPolicies: ["fs/edit-intent", "fs/write-intent"]
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: "chat",
|
|
28
|
-
name: "对话模式",
|
|
29
|
-
description: "只做对话:提问与联网(搜索、抓取)三件工具,不注入系统提示词、工作区指令与技能目录。",
|
|
30
|
-
persona: CHAT_PERSONA,
|
|
31
|
-
role: ["main"],
|
|
32
|
-
allowTools: [
|
|
33
|
-
"ask_user_question",
|
|
34
|
-
"web_search",
|
|
35
|
-
"web_fetch"
|
|
36
|
-
],
|
|
37
|
-
instructions: false,
|
|
38
|
-
runtimeContext: false
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: NOOP_MODE_ID,
|
|
42
|
-
name: "原样模式",
|
|
43
|
-
description: "与上游一致:不加人格提示词、不收窄工具与技能、policy 规则全开、官方注入面照旧。",
|
|
44
|
-
role: ["main", "subagent"]
|
|
45
|
-
}
|
|
46
|
-
];
|
|
47
|
-
// src/rows.ts
|
|
48
|
-
function list(values) {
|
|
49
|
-
return values === void 0 || values.length === 0 ? void 0 : [...values];
|
|
50
|
-
}
|
|
51
|
-
function modeConfig(source) {
|
|
52
|
-
const presetsOnly = list(source.presetsOnly);
|
|
53
|
-
const allowTools = list(source.allowTools);
|
|
54
|
-
const denyTools = list(source.denyTools);
|
|
55
|
-
const allowSkills = list(source.allowSkills);
|
|
56
|
-
const denySkills = list(source.denySkills);
|
|
57
|
-
const allowPolicies = list(source.allowPolicies);
|
|
58
|
-
const denyPolicies = list(source.denyPolicies);
|
|
59
|
-
return {
|
|
60
|
-
...presetsOnly === void 0 ? {} : { presetsOnly },
|
|
61
|
-
name: source.name,
|
|
62
|
-
description: source.description,
|
|
63
|
-
...source.role === void 0 ? {} : { role: [...source.role] },
|
|
64
|
-
...source.persona === void 0 ? {} : { persona: { ...source.persona } },
|
|
65
|
-
...allowTools === void 0 ? {} : { allowTools },
|
|
66
|
-
...denyTools === void 0 ? {} : { denyTools },
|
|
67
|
-
...allowSkills === void 0 ? {} : { allowSkills },
|
|
68
|
-
...denySkills === void 0 ? {} : { denySkills },
|
|
69
|
-
...allowPolicies === void 0 ? {} : { allowPolicies },
|
|
70
|
-
...denyPolicies === void 0 ? {} : { denyPolicies },
|
|
71
|
-
...source.instructions === void 0 ? {} : { instructions: source.instructions },
|
|
72
|
-
...source.skills === void 0 ? {} : { skills: source.skills },
|
|
73
|
-
...source.runtimeContext === void 0 ? {} : { runtimeContext: source.runtimeContext },
|
|
74
|
-
...source.defaultModel === void 0 ? {} : { defaultModel: { ...source.defaultModel } }
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function sessionModeRows() {
|
|
78
|
-
return [{ insert: [{
|
|
79
|
-
id: "session-mode",
|
|
80
|
-
name: "@morlay/dsh-session-mode",
|
|
81
|
-
config: {
|
|
82
|
-
default: DEFAULT_MODE,
|
|
83
|
-
modes: Object.fromEntries(MODE_SOURCES.map((source) => [source.id, modeConfig(source)]))
|
|
84
|
-
}
|
|
85
|
-
}] }];
|
|
86
|
-
}
|
|
87
|
-
exports.sessionModeRows = sessionModeRows;
|
|
2
|
+
const require_rows = require("./rows-BT6Fpq-E.cjs");
|
|
3
|
+
exports.modeConfig = require_rows.modeConfig;
|
|
4
|
+
exports.sessionModeRows = require_rows.sessionModeRows;
|
package/dist/rows.d.mts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
import { n as PolicyName } from "./shared-R2j0SuWy.mjs";
|
|
2
|
+
interface ModeSource {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly presetsOnly?: readonly string[];
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly role?: readonly ("main" | "subagent")[];
|
|
8
|
+
readonly persona?: {
|
|
9
|
+
readonly prefix?: string;
|
|
10
|
+
readonly suffix?: string;
|
|
11
|
+
};
|
|
12
|
+
readonly allowTools?: readonly string[];
|
|
13
|
+
readonly denyTools?: readonly string[];
|
|
14
|
+
readonly allowSkills?: readonly string[];
|
|
15
|
+
readonly denySkills?: readonly string[];
|
|
16
|
+
readonly allowPolicies?: readonly PolicyName[];
|
|
17
|
+
readonly denyPolicies?: readonly PolicyName[];
|
|
18
|
+
readonly instructions?: boolean;
|
|
19
|
+
readonly skills?: boolean;
|
|
20
|
+
readonly dropSections?: readonly string[];
|
|
21
|
+
readonly runtimeContext?: boolean;
|
|
22
|
+
readonly defaultModel?: ModeModelSource;
|
|
23
|
+
}
|
|
24
|
+
interface ModeModelSource {
|
|
25
|
+
readonly provider: string;
|
|
26
|
+
readonly model: string;
|
|
27
|
+
readonly reasoningEffort?: string;
|
|
28
|
+
}
|
|
1
29
|
export interface PatchRow {
|
|
2
30
|
readonly insert?: readonly RowEntry[];
|
|
3
31
|
}
|
|
@@ -6,4 +34,6 @@ export interface RowEntry {
|
|
|
6
34
|
readonly name: string;
|
|
7
35
|
readonly config?: Readonly<Record<string, unknown>>;
|
|
8
36
|
}
|
|
9
|
-
export declare function
|
|
37
|
+
export declare function modeConfig(source: ModeSource): Record<string, unknown>;
|
|
38
|
+
export declare function sessionModeRows(): readonly PatchRow[];
|
|
39
|
+
export {};
|