dsh-prompt-customizer 0.4.0 → 0.4.2
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/LICENSE +21 -21
- package/README.en.md +278 -227
- package/README.i18n.yaml +2 -2
- package/README.md +278 -227
- package/client/client.js +82 -80
- package/client/client.js.map +1 -1
- package/cordis.patch.yml +8 -8
- package/lib/catalog.js +131 -131
- package/lib/effective.js +161 -158
- package/lib/index.js +943 -943
- package/lib/promotion.js +80 -80
- package/lib/schema.js +124 -124
- package/lib/sectionOps.d.mts +32 -32
- package/lib/sectionOps.mjs +128 -133
- package/lib/store.js +124 -124
- package/lib/vars.js +147 -147
- package/package.json +84 -64
- package/src/client/PresetsTab.tsx +281 -281
- package/src/client/PreviewTab.tsx +91 -91
- package/src/client/PreviewTools.tsx +33 -33
- package/src/client/SectionsTab.tsx +539 -556
- package/src/client/ToolsTab.tsx +293 -266
- package/src/client/index.ts +433 -422
- package/src/client/locales.ts +263 -259
- package/src/client/preset-io.ts +226 -226
- package/src/client/presets.ts +413 -408
- package/src/client/styles.ts +49 -49
- package/src/client/types.ts +128 -128
package/lib/promotion.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Epoch-aware 晋级 tracker —— 行为对标 agent-presets 实验预设里的
|
|
3
|
-
* compaction-epoch.mjs:晋级由 durable 会话事件推导(默认首个
|
|
4
|
-
* `tool/call` 或 `assistant/message`),compaction 之后复位(首个压缩后
|
|
5
|
-
* 请求回到 bootstrap 态,直到新的晋级信号),subagent 视为恒已晋级。
|
|
6
|
-
*
|
|
7
|
-
* 状态按 session.id 记忆,冷会话扫一遍 durable log 后 O(1),因此 resume
|
|
8
|
-
* / reload 重建出相同的阶段。
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/** 默认的晋级信号事件。 */
|
|
12
|
-
const DEFAULT_PROMOTE_EVENTS = ['tool/call', 'assistant/message']
|
|
13
|
-
|
|
14
|
-
/** 构建一个晋级 tracker;promoteEvents 可换成单事件数组。 */
|
|
15
|
-
export function createPromotion(promoteEvents = DEFAULT_PROMOTE_EVENTS) {
|
|
16
|
-
const promote = new Set(promoteEvents)
|
|
17
|
-
/** sessionId -> { boundary, promoted } */
|
|
18
|
-
const state = new Map()
|
|
19
|
-
|
|
20
|
-
/** 从 durable log 冷扫描。 */
|
|
21
|
-
const scan = (session) => {
|
|
22
|
-
let boundary = -1
|
|
23
|
-
let promoted = false
|
|
24
|
-
for (const event of session.events ?? []) {
|
|
25
|
-
const seq = event.seq ?? 0 // 没有 seq 的事件视为边界之后
|
|
26
|
-
if (event.type === 'compaction/end') {
|
|
27
|
-
boundary = seq
|
|
28
|
-
promoted = false
|
|
29
|
-
continue
|
|
30
|
-
}
|
|
31
|
-
if (promote.has(event.type) && seq > boundary) promoted = true
|
|
32
|
-
}
|
|
33
|
-
const entry = { boundary, promoted }
|
|
34
|
-
state.set(session.id, entry)
|
|
35
|
-
return entry
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
/**
|
|
40
|
-
* 当前 agent 的阶段。agent 缺席(纯清单读取等)或子代理一律已晋级;
|
|
41
|
-
* ponytail: 只覆盖 compaction 边界这一种 epoch,未跟踪 fork 语义。
|
|
42
|
-
* 升级路径:参照 anchored-standard 的 fork-aware 边界扩展 scan。
|
|
43
|
-
*/
|
|
44
|
-
status(agent) {
|
|
45
|
-
const session = agent?.session
|
|
46
|
-
if (!session) return { boundary: -1, promoted: true }
|
|
47
|
-
if ((session.header?.delegationDepth ?? 0) > 0) return { boundary: -1, promoted: true }
|
|
48
|
-
return state.get(session.id) ?? scan(session)
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
/** 增量喂入 `session/event`,避免每次装配全量扫描。 */
|
|
52
|
-
observe(session, event) {
|
|
53
|
-
const entry = state.get(session.id)
|
|
54
|
-
if (entry === undefined) return
|
|
55
|
-
const seq = event.seq ?? 0
|
|
56
|
-
if (event.type === 'compaction/end') {
|
|
57
|
-
state.set(session.id, { boundary: seq, promoted: false })
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
if (promote.has(event.type) && seq > entry.boundary && !entry.promoted) {
|
|
61
|
-
state.set(session.id, { ...entry, promoted: true })
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 解析一个会话所属的 agent 预设 id:header 记录创建时值,
|
|
69
|
-
* `agent-preset/selected` 事件记录空白期切换后的值,后者优先。
|
|
70
|
-
*/
|
|
71
|
-
export function presetOfSession(session) {
|
|
72
|
-
if (!session) return undefined
|
|
73
|
-
let preset = typeof session.header?.agentPreset === 'string' ? session.header.agentPreset : undefined
|
|
74
|
-
for (const event of session.events ?? []) {
|
|
75
|
-
if (event.type === 'agent-preset/selected' && typeof event.data?.agentPreset === 'string') {
|
|
76
|
-
preset = event.data.agentPreset
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return preset
|
|
80
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Epoch-aware 晋级 tracker —— 行为对标 agent-presets 实验预设里的
|
|
3
|
+
* compaction-epoch.mjs:晋级由 durable 会话事件推导(默认首个
|
|
4
|
+
* `tool/call` 或 `assistant/message`),compaction 之后复位(首个压缩后
|
|
5
|
+
* 请求回到 bootstrap 态,直到新的晋级信号),subagent 视为恒已晋级。
|
|
6
|
+
*
|
|
7
|
+
* 状态按 session.id 记忆,冷会话扫一遍 durable log 后 O(1),因此 resume
|
|
8
|
+
* / reload 重建出相同的阶段。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** 默认的晋级信号事件。 */
|
|
12
|
+
const DEFAULT_PROMOTE_EVENTS = ['tool/call', 'assistant/message']
|
|
13
|
+
|
|
14
|
+
/** 构建一个晋级 tracker;promoteEvents 可换成单事件数组。 */
|
|
15
|
+
export function createPromotion(promoteEvents = DEFAULT_PROMOTE_EVENTS) {
|
|
16
|
+
const promote = new Set(promoteEvents)
|
|
17
|
+
/** sessionId -> { boundary, promoted } */
|
|
18
|
+
const state = new Map()
|
|
19
|
+
|
|
20
|
+
/** 从 durable log 冷扫描。 */
|
|
21
|
+
const scan = (session) => {
|
|
22
|
+
let boundary = -1
|
|
23
|
+
let promoted = false
|
|
24
|
+
for (const event of session.events ?? []) {
|
|
25
|
+
const seq = event.seq ?? 0 // 没有 seq 的事件视为边界之后
|
|
26
|
+
if (event.type === 'compaction/end') {
|
|
27
|
+
boundary = seq
|
|
28
|
+
promoted = false
|
|
29
|
+
continue
|
|
30
|
+
}
|
|
31
|
+
if (promote.has(event.type) && seq > boundary) promoted = true
|
|
32
|
+
}
|
|
33
|
+
const entry = { boundary, promoted }
|
|
34
|
+
state.set(session.id, entry)
|
|
35
|
+
return entry
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
/**
|
|
40
|
+
* 当前 agent 的阶段。agent 缺席(纯清单读取等)或子代理一律已晋级;
|
|
41
|
+
* ponytail: 只覆盖 compaction 边界这一种 epoch,未跟踪 fork 语义。
|
|
42
|
+
* 升级路径:参照 anchored-standard 的 fork-aware 边界扩展 scan。
|
|
43
|
+
*/
|
|
44
|
+
status(agent) {
|
|
45
|
+
const session = agent?.session
|
|
46
|
+
if (!session) return { boundary: -1, promoted: true }
|
|
47
|
+
if ((session.header?.delegationDepth ?? 0) > 0) return { boundary: -1, promoted: true }
|
|
48
|
+
return state.get(session.id) ?? scan(session)
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/** 增量喂入 `session/event`,避免每次装配全量扫描。 */
|
|
52
|
+
observe(session, event) {
|
|
53
|
+
const entry = state.get(session.id)
|
|
54
|
+
if (entry === undefined) return
|
|
55
|
+
const seq = event.seq ?? 0
|
|
56
|
+
if (event.type === 'compaction/end') {
|
|
57
|
+
state.set(session.id, { boundary: seq, promoted: false })
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
if (promote.has(event.type) && seq > entry.boundary && !entry.promoted) {
|
|
61
|
+
state.set(session.id, { ...entry, promoted: true })
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 解析一个会话所属的 agent 预设 id:header 记录创建时值,
|
|
69
|
+
* `agent-preset/selected` 事件记录空白期切换后的值,后者优先。
|
|
70
|
+
*/
|
|
71
|
+
export function presetOfSession(session) {
|
|
72
|
+
if (!session) return undefined
|
|
73
|
+
let preset = typeof session.header?.agentPreset === 'string' ? session.header.agentPreset : undefined
|
|
74
|
+
for (const event of session.events ?? []) {
|
|
75
|
+
if (event.type === 'agent-preset/selected' && typeof event.data?.agentPreset === 'string') {
|
|
76
|
+
preset = event.data.agentPreset
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return preset
|
|
80
|
+
}
|
package/lib/schema.js
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import Schema from '@deepseek-ai/schemastery'
|
|
2
|
-
import { DEFAULT_ENV_BLOCKLIST } from './vars.js'
|
|
3
|
-
|
|
4
|
-
/** 本插件的设置命名空间(小写 kebab-case)。 */
|
|
5
|
-
export const NS = 'prompt-customizer'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 插件的配置 schema,同时作为设置命名空间的 schema。
|
|
9
|
-
* GUI 的编辑以这个形状写入 `~/.dsh/settings.yaml`。
|
|
10
|
-
*/
|
|
11
|
-
export const Config = Schema.object({
|
|
12
|
-
//
|
|
13
|
-
sections: Schema.array(Schema.string()).default([]),
|
|
14
|
-
// 每阶段独立段屏蔽(与 tools 阶段化对称):引导期 /
|
|
15
|
-
//
|
|
16
|
-
sectionsBootstrap: Schema.array(Schema.string()).default([]),
|
|
17
|
-
sectionsCompaction: Schema.array(Schema.string()).default([]),
|
|
18
|
-
// 按名称替换某个段的文本(保持原顺序)。
|
|
19
|
-
replace: Schema.dict(Schema.string()).default({}),
|
|
20
|
-
// 注入 / 覆盖段(按 名称 + 顺序 + 文本)。`custom` 标记本插件生成的段
|
|
21
|
-
// (隐藏标记,用于识别其为可删除,跨预设依然成立,不依赖名字碰撞)。
|
|
22
|
-
// `phase` 控制阶段生效:`always` 恒定;`bootstrap` 只在会话未晋级时注入;
|
|
23
|
-
// `compaction` 只在「压缩后仍未晋级」时注入(独立于 bootstrap,拥有自己的
|
|
24
|
-
// order 空间);`active` 只在晋级后注入(晋级 = 首个 durable 的 tool/call
|
|
25
|
-
// 或 assistant/message;compaction 之后复位,subagent 视为已晋级)。
|
|
26
|
-
inject: Schema.array(Schema.object({
|
|
27
|
-
name: Schema.string().required(),
|
|
28
|
-
order: Schema.number().default(120),
|
|
29
|
-
text: Schema.string().required(),
|
|
30
|
-
phase: Schema.string().default('always'),
|
|
31
|
-
custom: Schema.boolean().default(false),
|
|
32
|
-
})).default([]),
|
|
33
|
-
// 工具目录过滤:只有 exclude 黑名单(列出的工具对模型隐藏)。三份名单对应三个
|
|
34
|
-
// 阶段,各管各的、互不继承:`exclude` 只在已晋级(常驻期)生效,`bootstrap`
|
|
35
|
-
// 只在未晋级(引导期)生效,`compaction` 只在「compaction 之后仍未晋级」的
|
|
36
|
-
// 阶段生效;空名单 = 该阶段什么都不隐藏。没有白名单语义 —— 见 lib/effective.js
|
|
37
|
-
// 的 applyToolFilter 注释。
|
|
38
|
-
tools: Schema.object({
|
|
39
|
-
exclude: Schema.array(Schema.string()).default([]),
|
|
40
|
-
// 该阶段要「加回来」的工具:被该阶段裁掉、但注册表里仍有的,装配时查回
|
|
41
|
-
// schema 追加。注册表里没有的(别的预设独有)加不进来。
|
|
42
|
-
add: Schema.array(Schema.string()).default([]),
|
|
43
|
-
bootstrap: Schema.object({
|
|
44
|
-
exclude: Schema.array(Schema.string()).default([]),
|
|
45
|
-
add: Schema.array(Schema.string()).default([]),
|
|
46
|
-
}).default({}),
|
|
47
|
-
compaction: Schema.object({
|
|
48
|
-
exclude: Schema.array(Schema.string()).default([]),
|
|
49
|
-
add: Schema.array(Schema.string()).default([]),
|
|
50
|
-
}).default({}),
|
|
51
|
-
}).default({}),
|
|
52
|
-
// 强制覆盖(默认开):包装宿主的 assemble,直接从注册表原始段重建最终
|
|
53
|
-
// 提示词段 —— 预设插件的阶段裁段(实测 liangshen / warmupbetter 等 preset
|
|
54
|
-
// 过滤器全部 prepend: true)与宿主 complete 整段接管都无法再改写结果;
|
|
55
|
-
// tools / contexts 保持宿主与预设行为。设 false 退回瀑布流内过滤。
|
|
56
|
-
forceSections: Schema.boolean().default(true),
|
|
57
|
-
// process.env 变量黑名单:env 全量注册为提示词变量({{env_xxx}}),命中
|
|
58
|
-
// 本名单的键不注册 —— env 里常有密钥,进了提示词就会随请求发给模型。
|
|
59
|
-
// 条目支持 `*` 通配、大小写不敏感;预填常见密钥类键,界面可增删。
|
|
60
|
-
envBlocklist: Schema.array(Schema.string()).default(DEFAULT_ENV_BLOCKLIST),
|
|
61
|
-
// 预设:完整的定制快照(提示词 + 工具配置,含每阶段独立名单与阶段目录)。
|
|
62
|
-
presets: Schema.array(Schema.object({
|
|
63
|
-
id: Schema.string().required(),
|
|
64
|
-
name: Schema.string().required(),
|
|
65
|
-
data: Schema.object({
|
|
66
|
-
sections: Schema.array(Schema.string()),
|
|
67
|
-
// 每阶段独立段屏蔽名单:缺省 = 旧文件,应用时保留当前值不抹掉。
|
|
68
|
-
sectionsBootstrap: Schema.array(Schema.string()),
|
|
69
|
-
sectionsCompaction: Schema.array(Schema.string()),
|
|
70
|
-
replace: Schema.dict(Schema.string()),
|
|
71
|
-
// 相对顺序:每个条目记录它应跟随的前一段,以及这段属于哪个阶段
|
|
72
|
-
// (缺省 always = 旧快照的单一全局序;同名不同 phase 的条目 = 该段在
|
|
73
|
-
// 多个阶段各有自己的位置)。
|
|
74
|
-
order: Schema.array(Schema.object({
|
|
75
|
-
name: Schema.string().required(),
|
|
76
|
-
after: Schema.string(),
|
|
77
|
-
text: Schema.string(),
|
|
78
|
-
custom: Schema.boolean().default(false),
|
|
79
|
-
phase: Schema.string(),
|
|
80
|
-
})),
|
|
81
|
-
tools: Schema.object({
|
|
82
|
-
exclude: Schema.array(Schema.string()),
|
|
83
|
-
add: Schema.array(Schema.string()),
|
|
84
|
-
bootstrap: Schema.object({
|
|
85
|
-
exclude: Schema.array(Schema.string()),
|
|
86
|
-
add: Schema.array(Schema.string()),
|
|
87
|
-
}),
|
|
88
|
-
compaction: Schema.object({
|
|
89
|
-
exclude: Schema.array(Schema.string()),
|
|
90
|
-
add: Schema.array(Schema.string()),
|
|
91
|
-
}),
|
|
92
|
-
}),
|
|
93
|
-
}),
|
|
94
|
-
})).default([]),
|
|
95
|
-
// 当前已应用预设的 id(同一时间只有一个生效)。
|
|
96
|
-
activePreset: Schema.string(),
|
|
97
|
-
// 按 agent 预设 id 的字段级覆盖:某个 agent 预设的 override 中,非空的
|
|
98
|
-
// 字段整体接管全局默认,空缺 / 空列表的字段继续回落全局。键是
|
|
99
|
-
// dsh-agent-presets 的预设目录名(即会话 header.agentPreset 记录的 id)。
|
|
100
|
-
overrides: Schema.dict(Schema.object({
|
|
101
|
-
sections: Schema.array(Schema.string()),
|
|
102
|
-
sectionsBootstrap: Schema.array(Schema.string()),
|
|
103
|
-
sectionsCompaction: Schema.array(Schema.string()),
|
|
104
|
-
replace: Schema.dict(Schema.string()),
|
|
105
|
-
inject: Schema.array(Schema.object({
|
|
106
|
-
name: Schema.string().required(),
|
|
107
|
-
order: Schema.number().default(120),
|
|
108
|
-
text: Schema.string().required(),
|
|
109
|
-
phase: Schema.string().default('always'),
|
|
110
|
-
custom: Schema.boolean().default(false),
|
|
111
|
-
})),
|
|
112
|
-
tools: Schema.object({
|
|
113
|
-
exclude: Schema.array(Schema.string()),
|
|
114
|
-
add: Schema.array(Schema.string()),
|
|
115
|
-
bootstrap: Schema.object({
|
|
116
|
-
exclude: Schema.array(Schema.string()),
|
|
117
|
-
add: Schema.array(Schema.string()),
|
|
118
|
-
}),
|
|
119
|
-
compaction: Schema.object({
|
|
120
|
-
exclude: Schema.array(Schema.string()),
|
|
121
|
-
add: Schema.array(Schema.string()),
|
|
122
|
-
}),
|
|
123
|
-
}),
|
|
124
|
-
})).default({}),
|
|
1
|
+
import Schema from '@deepseek-ai/schemastery'
|
|
2
|
+
import { DEFAULT_ENV_BLOCKLIST } from './vars.js'
|
|
3
|
+
|
|
4
|
+
/** 本插件的设置命名空间(小写 kebab-case)。 */
|
|
5
|
+
export const NS = 'prompt-customizer'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 插件的配置 schema,同时作为设置命名空间的 schema。
|
|
9
|
+
* GUI 的编辑以这个形状写入 `~/.dsh/settings.yaml`。
|
|
10
|
+
*/
|
|
11
|
+
export const Config = Schema.object({
|
|
12
|
+
// 按名称屏蔽这些提示词段:常驻期(晋级后)的独立屏蔽名单。
|
|
13
|
+
sections: Schema.array(Schema.string()).default([]),
|
|
14
|
+
// 每阶段独立段屏蔽(与 tools 阶段化对称):引导期 / 压缩受控期各自的
|
|
15
|
+
// 屏蔽名单。三态互不继承、互不影响 —— 一个阶段的屏蔽不波及另一个阶段。
|
|
16
|
+
sectionsBootstrap: Schema.array(Schema.string()).default([]),
|
|
17
|
+
sectionsCompaction: Schema.array(Schema.string()).default([]),
|
|
18
|
+
// 按名称替换某个段的文本(保持原顺序)。
|
|
19
|
+
replace: Schema.dict(Schema.string()).default({}),
|
|
20
|
+
// 注入 / 覆盖段(按 名称 + 顺序 + 文本)。`custom` 标记本插件生成的段
|
|
21
|
+
// (隐藏标记,用于识别其为可删除,跨预设依然成立,不依赖名字碰撞)。
|
|
22
|
+
// `phase` 控制阶段生效:`always` 恒定;`bootstrap` 只在会话未晋级时注入;
|
|
23
|
+
// `compaction` 只在「压缩后仍未晋级」时注入(独立于 bootstrap,拥有自己的
|
|
24
|
+
// order 空间);`active` 只在晋级后注入(晋级 = 首个 durable 的 tool/call
|
|
25
|
+
// 或 assistant/message;compaction 之后复位,subagent 视为已晋级)。
|
|
26
|
+
inject: Schema.array(Schema.object({
|
|
27
|
+
name: Schema.string().required(),
|
|
28
|
+
order: Schema.number().default(120),
|
|
29
|
+
text: Schema.string().required(),
|
|
30
|
+
phase: Schema.string().default('always'),
|
|
31
|
+
custom: Schema.boolean().default(false),
|
|
32
|
+
})).default([]),
|
|
33
|
+
// 工具目录过滤:只有 exclude 黑名单(列出的工具对模型隐藏)。三份名单对应三个
|
|
34
|
+
// 阶段,各管各的、互不继承:`exclude` 只在已晋级(常驻期)生效,`bootstrap`
|
|
35
|
+
// 只在未晋级(引导期)生效,`compaction` 只在「compaction 之后仍未晋级」的
|
|
36
|
+
// 阶段生效;空名单 = 该阶段什么都不隐藏。没有白名单语义 —— 见 lib/effective.js
|
|
37
|
+
// 的 applyToolFilter 注释。
|
|
38
|
+
tools: Schema.object({
|
|
39
|
+
exclude: Schema.array(Schema.string()).default([]),
|
|
40
|
+
// 该阶段要「加回来」的工具:被该阶段裁掉、但注册表里仍有的,装配时查回
|
|
41
|
+
// schema 追加。注册表里没有的(别的预设独有)加不进来。
|
|
42
|
+
add: Schema.array(Schema.string()).default([]),
|
|
43
|
+
bootstrap: Schema.object({
|
|
44
|
+
exclude: Schema.array(Schema.string()).default([]),
|
|
45
|
+
add: Schema.array(Schema.string()).default([]),
|
|
46
|
+
}).default({}),
|
|
47
|
+
compaction: Schema.object({
|
|
48
|
+
exclude: Schema.array(Schema.string()).default([]),
|
|
49
|
+
add: Schema.array(Schema.string()).default([]),
|
|
50
|
+
}).default({}),
|
|
51
|
+
}).default({}),
|
|
52
|
+
// 强制覆盖(默认开):包装宿主的 assemble,直接从注册表原始段重建最终
|
|
53
|
+
// 提示词段 —— 预设插件的阶段裁段(实测 liangshen / warmupbetter 等 preset
|
|
54
|
+
// 过滤器全部 prepend: true)与宿主 complete 整段接管都无法再改写结果;
|
|
55
|
+
// tools / contexts 保持宿主与预设行为。设 false 退回瀑布流内过滤。
|
|
56
|
+
forceSections: Schema.boolean().default(true),
|
|
57
|
+
// process.env 变量黑名单:env 全量注册为提示词变量({{env_xxx}}),命中
|
|
58
|
+
// 本名单的键不注册 —— env 里常有密钥,进了提示词就会随请求发给模型。
|
|
59
|
+
// 条目支持 `*` 通配、大小写不敏感;预填常见密钥类键,界面可增删。
|
|
60
|
+
envBlocklist: Schema.array(Schema.string()).default(DEFAULT_ENV_BLOCKLIST),
|
|
61
|
+
// 预设:完整的定制快照(提示词 + 工具配置,含每阶段独立名单与阶段目录)。
|
|
62
|
+
presets: Schema.array(Schema.object({
|
|
63
|
+
id: Schema.string().required(),
|
|
64
|
+
name: Schema.string().required(),
|
|
65
|
+
data: Schema.object({
|
|
66
|
+
sections: Schema.array(Schema.string()),
|
|
67
|
+
// 每阶段独立段屏蔽名单:缺省 = 旧文件,应用时保留当前值不抹掉。
|
|
68
|
+
sectionsBootstrap: Schema.array(Schema.string()),
|
|
69
|
+
sectionsCompaction: Schema.array(Schema.string()),
|
|
70
|
+
replace: Schema.dict(Schema.string()),
|
|
71
|
+
// 相对顺序:每个条目记录它应跟随的前一段,以及这段属于哪个阶段
|
|
72
|
+
// (缺省 always = 旧快照的单一全局序;同名不同 phase 的条目 = 该段在
|
|
73
|
+
// 多个阶段各有自己的位置)。
|
|
74
|
+
order: Schema.array(Schema.object({
|
|
75
|
+
name: Schema.string().required(),
|
|
76
|
+
after: Schema.string(),
|
|
77
|
+
text: Schema.string(),
|
|
78
|
+
custom: Schema.boolean().default(false),
|
|
79
|
+
phase: Schema.string(),
|
|
80
|
+
})),
|
|
81
|
+
tools: Schema.object({
|
|
82
|
+
exclude: Schema.array(Schema.string()),
|
|
83
|
+
add: Schema.array(Schema.string()),
|
|
84
|
+
bootstrap: Schema.object({
|
|
85
|
+
exclude: Schema.array(Schema.string()),
|
|
86
|
+
add: Schema.array(Schema.string()),
|
|
87
|
+
}),
|
|
88
|
+
compaction: Schema.object({
|
|
89
|
+
exclude: Schema.array(Schema.string()),
|
|
90
|
+
add: Schema.array(Schema.string()),
|
|
91
|
+
}),
|
|
92
|
+
}),
|
|
93
|
+
}),
|
|
94
|
+
})).default([]),
|
|
95
|
+
// 当前已应用预设的 id(同一时间只有一个生效)。
|
|
96
|
+
activePreset: Schema.string(),
|
|
97
|
+
// 按 agent 预设 id 的字段级覆盖:某个 agent 预设的 override 中,非空的
|
|
98
|
+
// 字段整体接管全局默认,空缺 / 空列表的字段继续回落全局。键是
|
|
99
|
+
// dsh-agent-presets 的预设目录名(即会话 header.agentPreset 记录的 id)。
|
|
100
|
+
overrides: Schema.dict(Schema.object({
|
|
101
|
+
sections: Schema.array(Schema.string()),
|
|
102
|
+
sectionsBootstrap: Schema.array(Schema.string()),
|
|
103
|
+
sectionsCompaction: Schema.array(Schema.string()),
|
|
104
|
+
replace: Schema.dict(Schema.string()),
|
|
105
|
+
inject: Schema.array(Schema.object({
|
|
106
|
+
name: Schema.string().required(),
|
|
107
|
+
order: Schema.number().default(120),
|
|
108
|
+
text: Schema.string().required(),
|
|
109
|
+
phase: Schema.string().default('always'),
|
|
110
|
+
custom: Schema.boolean().default(false),
|
|
111
|
+
})),
|
|
112
|
+
tools: Schema.object({
|
|
113
|
+
exclude: Schema.array(Schema.string()),
|
|
114
|
+
add: Schema.array(Schema.string()),
|
|
115
|
+
bootstrap: Schema.object({
|
|
116
|
+
exclude: Schema.array(Schema.string()),
|
|
117
|
+
add: Schema.array(Schema.string()),
|
|
118
|
+
}),
|
|
119
|
+
compaction: Schema.object({
|
|
120
|
+
exclude: Schema.array(Schema.string()),
|
|
121
|
+
add: Schema.array(Schema.string()),
|
|
122
|
+
}),
|
|
123
|
+
}),
|
|
124
|
+
})).default({}),
|
|
125
125
|
})
|
package/lib/sectionOps.d.mts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/** sectionOps.mjs 的类型声明(仅供电类型检查;运行时代码在 .mjs 中)。 */
|
|
2
|
-
|
|
3
|
-
/** 名义阶段键:引导期 / 常驻期 / 压缩受控期(恒定全部显示)。 */
|
|
4
|
-
export type PhaseKey = 'bootstrap' | 'active' | 'compaction'
|
|
5
|
-
|
|
6
|
-
export function sectionListOf(key: PhaseKey): 'global' | 'bootstrap' | 'compaction'
|
|
7
|
-
export function injectPhaseOf(key: PhaseKey): 'bootstrap' | 'active' | 'compaction'
|
|
8
|
-
export function acceptsInjectFor(key: PhaseKey, phase: string): boolean
|
|
9
|
-
export function deniedNames(cfg: unknown, key: PhaseKey): string[]
|
|
10
|
-
/** 本部分当前的注入身份:phase 注入阶段、names 可见段名、custom 自定义段名、
|
|
11
|
-
* text 本阶段生效的用户文本(自定义段文本 + 系统段在本阶段的替换文本)、
|
|
12
|
-
* order 本阶段草稿序(都是 name → 值 的映射 / 集合)。 */
|
|
13
|
-
export function injectedAt(cfg: unknown, key: PhaseKey): {
|
|
14
|
-
phase: 'bootstrap' | 'active' | 'compaction'
|
|
15
|
-
names: Set<string>
|
|
16
|
-
custom: Set<string>
|
|
17
|
-
text: Map<string, string>
|
|
18
|
-
order: Map<string, number>
|
|
19
|
-
}
|
|
20
|
-
export function blockPatch(cfg: unknown, key: PhaseKey, name: string, blocked: boolean): Record<string, unknown>
|
|
21
|
-
export function reorderInsert<T extends object>(
|
|
22
|
-
rows: T[],
|
|
23
|
-
dragName: string,
|
|
24
|
-
targetName: string,
|
|
25
|
-
pos: 'above' | 'below',
|
|
26
|
-
newRow?: T | null,
|
|
27
|
-
): T[] | null
|
|
28
|
-
export function phaseInjectEntries<T extends object>(
|
|
29
|
-
cfg: unknown,
|
|
30
|
-
key: PhaseKey,
|
|
31
|
-
rows: T[],
|
|
32
|
-
): Array<Record<string, unknown>>
|
|
1
|
+
/** sectionOps.mjs 的类型声明(仅供电类型检查;运行时代码在 .mjs 中)。 */
|
|
2
|
+
|
|
3
|
+
/** 名义阶段键:引导期 / 常驻期 / 压缩受控期(恒定全部显示)。 */
|
|
4
|
+
export type PhaseKey = 'bootstrap' | 'active' | 'compaction'
|
|
5
|
+
|
|
6
|
+
export function sectionListOf(key: PhaseKey): 'global' | 'bootstrap' | 'compaction'
|
|
7
|
+
export function injectPhaseOf(key: PhaseKey): 'bootstrap' | 'active' | 'compaction'
|
|
8
|
+
export function acceptsInjectFor(key: PhaseKey, phase: string): boolean
|
|
9
|
+
export function deniedNames(cfg: unknown, key: PhaseKey): string[]
|
|
10
|
+
/** 本部分当前的注入身份:phase 注入阶段、names 可见段名、custom 自定义段名、
|
|
11
|
+
* text 本阶段生效的用户文本(自定义段文本 + 系统段在本阶段的替换文本)、
|
|
12
|
+
* order 本阶段草稿序(都是 name → 值 的映射 / 集合)。 */
|
|
13
|
+
export function injectedAt(cfg: unknown, key: PhaseKey): {
|
|
14
|
+
phase: 'bootstrap' | 'active' | 'compaction'
|
|
15
|
+
names: Set<string>
|
|
16
|
+
custom: Set<string>
|
|
17
|
+
text: Map<string, string>
|
|
18
|
+
order: Map<string, number>
|
|
19
|
+
}
|
|
20
|
+
export function blockPatch(cfg: unknown, key: PhaseKey, name: string, blocked: boolean): Record<string, unknown>
|
|
21
|
+
export function reorderInsert<T extends object>(
|
|
22
|
+
rows: T[],
|
|
23
|
+
dragName: string,
|
|
24
|
+
targetName: string,
|
|
25
|
+
pos: 'above' | 'below',
|
|
26
|
+
newRow?: T | null,
|
|
27
|
+
): T[] | null
|
|
28
|
+
export function phaseInjectEntries<T extends object>(
|
|
29
|
+
cfg: unknown,
|
|
30
|
+
key: PhaseKey,
|
|
31
|
+
rows: T[],
|
|
32
|
+
): Array<Record<string, unknown>>
|