dsh-session-superagent 0.10.7 → 0.10.8

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/AGENTS.md CHANGED
@@ -129,7 +129,7 @@ node scripts/render-preview.mjs preview.html
129
129
 
130
130
  ## 十、当前基线
131
131
 
132
- 0.10.7;全量 **827/827**、preflight **41/41**、UI **11/11**、真实 Chromium **47/47**。
132
+ 0.10.8;全量 **873/873**、preflight **42 项**、UI **11/11**、真实 Chromium **47/47**。
133
133
  未验:真实 DSH WebView 重载后的读屏 / 触摸 / IME、真实 GitHub/Gitee 写操作。没有实测不得写成通过。
134
134
 
135
135
  ## 十一、Issue/PR 回复边界
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  格式参照 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
4
 
5
+ ## [0.10.8] - 2026-11-08 —— 门禁 v2(规则真实启停 + 发送前 CLI + 面板 + 发布基线)
6
+
7
+ - 门禁子包 `@mycf711/dsh-gate` `0.1.0` → `0.1.1`:规则级真实启停(缺省 `enabled:true`、`false` 真停用、
8
+ 后层完整规则可复启),发送前 CLI 硬门禁失败不请求模型。
9
+ - 设置页门禁面板:开关取四层合并结果;保存时未改语义原样写回 `semantic`(`baseURL` / `mode` /
10
+ `timeoutMs` / `maxInputChars` 等未暴露字段不丢);本层有 `extends` 时拒绝保存并给出配置文件路径,
11
+ 不整层重写;更后层(项目 / 本地)停用时开关 disabled 并标注来源层;`SegmentedControl` 优先委托
12
+ 官方原语,缺导出时回退可实现方向键 / Home / End / roving tab stop。
13
+ - 发布基线修复:`scripts/sync-profile.mjs` 对门禁子包改为**逐文件内容指纹**
14
+ (`package.json` + `lib/**/*.js` + `bin/**/*.mjs` + `gates/**/*.json`),`--check` 单列
15
+ 「门禁子包漂移」并 `exit 1`,`--repair` 强制整目录同步 —— 修掉「只改 `lib/` 或
16
+ `gates/default.json`、版本没 bump 时 profile 假绿、`--repair` 也不替换」这一类问题。
17
+ - `scripts/verify-panel-chromium.mjs` 不再写死旧安装与本机临时仓库路径:仓库根按
18
+ `DSH_SUPERAGENT_REPO` → 脚本位置 → cwd;DSH 安装按 `DSH_ASAR`+`DSH_ELECTRON` →
19
+ `DSH_INSTALL_ROOT` → 扫描(取 `app.asar` mtime 最新,多套安装不静默验旧版);新增
20
+ `--print-paths` 探针。ego-browser 的 nodejs 沙箱不继承父进程 env,运行方式改为 prelude 注入。
21
+ - 边界:`sync-profile --repair` 只保证 profile **磁盘副本**与仓库一致;宿主已加载的模块要重载才生效。
22
+ - 验证:根 `npm test` **873/873**、gate 包 **133/133**、UI 审计 **11/11**、真实 Chromium **47/47**
23
+ (安装版前端 `0.2.2-rc.1`)、`preflight` 全量 **42/42**。Gitee ack 标签请求体沿用 0.10.7 的裸数组修复。
24
+
5
25
  ## [0.10.7] - 2026-11-08 —— Gitee ack 打标签修复
6
26
 
7
27
  - 修复 `addGiteeLabel` 的请求体:Gitee 规范(swagger `POST /v5/repos/{owner}/{repo}/issues/{number}/labels`)要求
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  </p>
11
11
 
12
12
  <p align="center">
13
- <a href="https://github.com/MYCF711/dsh-session-superagent/releases"><img src="https://img.shields.io/badge/version-0.10.7-green.svg" alt="version"></a>
13
+ <a href="https://github.com/MYCF711/dsh-session-superagent/releases"><img src="https://img.shields.io/badge/version-0.10.8-green.svg" alt="version"></a>
14
14
  <a href="https://www.npmjs.com/package/dsh-session-superagent"><img src="https://img.shields.io/npm/v/dsh-session-superagent?color=4D6BFE" alt="npm"></a>
15
15
  <img src="https://img.shields.io/badge/license-MIT-4D6BFE" alt="license">
16
16
  </p>
@@ -144,13 +144,13 @@ Gitee 没有 ETag,每轮会真读一次列表;私有仓库需要在面板里
144
144
 
145
145
  ## 验证
146
146
 
147
- 827 项单测、41 项 preflight、11 项 UI、47 项 Chromium 全绿(0.10.7)。
147
+ 873 项单测、42 项 preflight、11 项 UI、47 项 Chromium 全绿(0.10.8)。
148
148
 
149
149
  ## 数据来源
150
150
 
151
151
  | 说法 | 来源 |
152
152
  |---|---|
153
- | 版本 `0.10.7` | [package.json](package.json)、[npm](https://www.npmjs.com/package/dsh-session-superagent) |
153
+ | 版本 `0.10.8` | [package.json](package.json)、[npm](https://www.npmjs.com/package/dsh-session-superagent) |
154
154
  | 项目起点 | [deepseek-ai/dsh-superagent-prototype](https://github.com/deepseek-ai/dsh-superagent-prototype) |
155
155
  | DSH 原生 UI | [deepseek-ai/deepseek-harness](https://github.com/deepseek-ai/deepseek-harness)、`$DSH_HOME/DSH-UI-official.md`、`docs/ui-decomp/` |
156
156
  | 图标 | [DSH-X/docs/icon-app.png](https://github.com/yyh-001/DSH-X/blob/Staging/docs/icon-app.png)(MIT) |
package/client.js CHANGED
@@ -356,6 +356,7 @@ window.__ModuleLoader__.load({
356
356
  let hostInput = null
357
357
  let hostSwitch = null
358
358
  let hostSegmentedTabs = null
359
+ let hostSegmentedControl = null
359
360
  let hostTag = null
360
361
  let hostStateDot = null
361
362
  let hostPill = null
@@ -373,6 +374,8 @@ window.__ModuleLoader__.load({
373
374
  hostSwitch = primitives.Switch || null
374
375
  // SegmentedTabs 同样独立探测:缺导出时完整保留下方 SegTabs,不影响其它原语。
375
376
  hostSegmentedTabs = primitives.SegmentedTabs || null
377
+ // SegmentedControl 与 SegmentedTabs 是两个导出:缺导出时回退本地单选分段(方向键/Home/End 同语义)。
378
+ hostSegmentedControl = primitives.SegmentedControl || null
376
379
  // Tag 与 StateDot 各自独立探测:任何一个缺导出都只回退自己,不影响另一个或其它原语。
377
380
  hostTag = primitives.Tag || null
378
381
  hostStateDot = primitives.StateDot || null
@@ -391,6 +394,7 @@ window.__ModuleLoader__.load({
391
394
  hostInput = null
392
395
  hostSwitch = null
393
396
  hostSegmentedTabs = null
397
+ hostSegmentedControl = null
394
398
  hostTag = null
395
399
  hostStateDot = null
396
400
  hostPill = null
@@ -418,7 +422,7 @@ window.__ModuleLoader__.load({
418
422
  }
419
423
 
420
424
  // 客户端版本探针:每次模块加载写一次,用来确认浏览器里跑的是哪一版
421
- const CLIENT_VERSION = '0.10.7'
425
+ const CLIENT_VERSION = '0.10.8'
422
426
  // SEMVER_COMPARATOR_SOURCE_START
423
427
  // This block is duplicated verbatim in client.js because the browser UMD cannot import ESM.
424
428
  // test/update-semver.test.mjs audits both copies and exercises their behavior.
@@ -937,20 +941,57 @@ window.__ModuleLoader__.load({
937
941
  }
938
942
 
939
943
  /** 官方 SegmentedControl:单选分段(与 SegTabs 的页签语义不同,用于表单内的互斥选择)。 */
940
- function SegmentedControl({ options, value, onChange, label, disabled }) {
941
- // 官方分段控件是一行等宽格;`dt-segmented` 本身没写列模板,不补就会竖排(grid 默认单列)。
944
+ function SegmentedControl({ id, options, value, onChange, label, disabled }) {
945
+ // 官方组件自带方向键 / Home / End / 跳过 disabled / roving tab stop;这里只转发受控 props。
946
+ if (hostSegmentedControl) {
947
+ return h(hostSegmentedControl, { id, options, value, onChange, label, disabled })
948
+ }
949
+ // 老宿主完整保留本地实现 —— 键盘行为与官方对齐,不再只靠鼠标。
950
+ const buttons = useRef({})
951
+ const enabled = options.filter((option) => !(disabled || option.disabled))
952
+ const hasValue = options.some((option) => option.value === value)
953
+ const walk = (event) => {
954
+ const index = enabled.findIndex((option) => option.value === value)
955
+ const step = { ArrowRight: 1, ArrowLeft: -1 }[event.key]
956
+ let next
957
+ if (step !== undefined) {
958
+ if (enabled.length === 0) return
959
+ const from = index < 0 ? 0 : index
960
+ next = enabled[(from + step + enabled.length) % enabled.length]
961
+ } else if (event.key === 'Home') {
962
+ next = enabled[0]
963
+ } else if (event.key === 'End') {
964
+ next = enabled[enabled.length - 1]
965
+ } else {
966
+ return
967
+ }
968
+ if (!next) return
969
+ event.preventDefault()
970
+ if (next.value !== value) onChange(next.value)
971
+ // 焦点跟随:旧选中项变成 tabIndex=-1 后,键盘用户会掉出 radiogroup。
972
+ const node = buttons.current[next.value]
973
+ if (node && typeof node.focus === 'function') node.focus()
974
+ }
942
975
  return h('div', {
943
976
  className: 'dt-segmented',
977
+ id,
944
978
  role: 'radiogroup',
945
979
  'aria-label': label,
980
+ onKeyDown: walk,
946
981
  style: { gridTemplateColumns: 'repeat(' + options.length + ', minmax(0, 1fr))' },
947
982
  },
948
- options.map((option) => h('button', {
949
- key: option.value, type: 'button', role: 'radio',
950
- 'aria-checked': value === option.value, 'aria-selected': value === option.value,
951
- className: 'dt-segment', disabled: disabled || option.disabled,
952
- onClick: () => onChange(option.value),
953
- }, option.label)))
983
+ options.map((option, index) => {
984
+ const selected = option.value === value
985
+ const unavailable = Boolean(disabled || option.disabled)
986
+ return h('button', {
987
+ key: option.value, type: 'button', role: 'radio',
988
+ 'aria-checked': selected,
989
+ ref: (node) => { buttons.current[option.value] = node },
990
+ tabIndex: selected ? 0 : (hasValue ? -1 : (index === 0 ? 0 : -1)),
991
+ className: 'dt-segment', disabled: unavailable,
992
+ onClick: () => { if (!unavailable) onChange(option.value) },
993
+ }, option.label)
994
+ }))
954
995
  }
955
996
 
956
997
  /** 官方 DisclosureRow:折叠行的标准写法(Enter / 空格可切换,带 aria-expanded)。 */
@@ -2155,7 +2196,9 @@ window.__ModuleLoader__.load({
2155
2196
  { value: 'user', label: '我的' },
2156
2197
  { value: 'project', label: '项目' },
2157
2198
  ]
2158
- const GATE_LAYER_LABELS = { default: '默认', user: '我的', project: '项目' }
2199
+ const GATE_LAYER_LABELS = { default: '默认', user: '我的', project: '项目', local: '本地' }
2200
+ // 四层顺序:数值越大越靠后、优先级越高。面板只能写 user / project 两层。
2201
+ const GATE_LAYER_RANK = { default: 0, user: 1, project: 2, local: 3 }
2159
2202
  const GATE_SCOPE_HINTS = {
2160
2203
  default: '默认规则随包发布,这里只读;要调整就切到「我的」或「项目」。',
2161
2204
  user: '「我的」写到用户全局配置,本机所有仓库都生效。',
@@ -2178,27 +2221,40 @@ window.__ModuleLoader__.load({
2178
2221
  // 语义复审只对这两类触发生效(G1 契约);面板只如实说明,不另开判断。
2179
2222
  const GATE_SEMANTIC_TRIGGERS = ['merge', 'release']
2180
2223
 
2181
- /** 规则的可比较快照:只比会落盘的字段,`enabled` 是面板本地状态,不参与。 */
2224
+ /**
2225
+ * 规则的可比较快照:会落盘的字段,**包含** `enabled`(缺省 = 开)。
2226
+ * 不把开关算进来,「本层只有开关不同」就会被当成没改 → 不落盘,等于假启停。
2227
+ */
2182
2228
  const gateRuleKey = (rule) => JSON.stringify([
2183
2229
  rule.id, rule.label, rule.description || '', rule.severity || 'error',
2184
2230
  rule.triggers || null, rule.type, rule.pattern === undefined ? null : rule.pattern,
2185
2231
  rule.flags || '', rule.value === undefined ? null : rule.value, rule.message || '',
2232
+ rule.enabled !== false,
2186
2233
  ])
2187
2234
 
2188
- /** 本层之下最近的一版同名规则;返回 null = 这条规则是本层新增的。 */
2189
- const gateInheritedRule = (data, scope, id) => {
2190
- const chain = scope === 'user' ? ['default'] : scope === 'project' ? ['default', 'user'] : []
2191
- let found = null
2192
- for (const name of chain) {
2193
- const layer = data && data.scopes && data.scopes[name] && data.scopes[name].config
2194
- const rule = layer && Array.isArray(layer.rules) ? layer.rules.find((item) => item && item.id === id) : null
2195
- if (rule) found = rule
2235
+ /** 某一层的原始配置对象(GET /gates 的 scopes[scope].config);null = 这层没有文件。 */
2236
+ const gateRawLayer = (data, scope) => {
2237
+ const layer = data && data.scopes && data.scopes[scope] ? data.scopes[scope].config : null
2238
+ return layer && typeof layer === 'object' && !Array.isArray(layer) ? layer : null
2239
+ }
2240
+
2241
+ /**
2242
+ * 合并后是哪一层把这条规则写成停用的(取最靠后、也即真正生效的那一层)。
2243
+ * 返回层级名;'' = 没有哪一层显式停用(或这条规则来自 extends 基文件)。
2244
+ */
2245
+ const gateDisabledLayer = (data, id) => {
2246
+ let found = ''
2247
+ for (const name of ['default', 'user', 'project', 'local']) {
2248
+ const layer = gateRawLayer(data, name)
2249
+ const rules = layer && Array.isArray(layer.rules) ? layer.rules : []
2250
+ const rule = rules.find((item) => item && item.id === id)
2251
+ if (rule) found = rule.enabled === false ? name : ''
2196
2252
  }
2197
2253
  return found
2198
2254
  }
2199
2255
 
2200
- /** 这条规则被哪几层定义(卡片上的来源标签)。 */
2201
- const gateLayerNames = (data, ruleId) => ['default', 'user', 'project'].filter((name) => {
2256
+ /** 这条规则被哪几层定义(卡片上的来源标签;本地层也要显示,否则看不出是手工覆盖)。 */
2257
+ const gateLayerNames = (data, ruleId) => ['default', 'user', 'project', 'local'].filter((name) => {
2202
2258
  const layer = data && data.scopes && data.scopes[name] && data.scopes[name].config
2203
2259
  const rules = layer && Array.isArray(layer.rules) ? layer.rules : []
2204
2260
  return rules.some((rule) => rule && rule.id === ruleId)
@@ -2218,24 +2274,28 @@ window.__ModuleLoader__.load({
2218
2274
  }
2219
2275
  }
2220
2276
 
2221
- /** 草稿:规则取「生效集合」(四层合并结果),开关默认全开。 */
2277
+ /** 草稿:规则取「四层合并结果」,开关照合并后的真实状态(停用的就是关的)。 */
2222
2278
  const gateDraftOf = (data, scope) => {
2223
2279
  const rules = data && data.config && Array.isArray(data.config.rules) ? data.config.rules : []
2224
2280
  return {
2225
- rules: rules.map((rule) => ({ ...rule, enabled: true })),
2281
+ rules: rules.map((rule) => ({ ...rule, enabled: rule.enabled !== false })),
2226
2282
  semantic: gateSemanticOf(data, scope),
2227
2283
  }
2228
2284
  }
2229
2285
 
2230
- /** 落盘形状:只带不等同于下层的规则 —— 层里只有真正的覆盖,不会把默认规则冻进来。 */
2286
+ /**
2287
+ * 落盘形状:完整规则 + 布尔 `enabled`。
2288
+ * 复启也必须写完整规则 —— 只写 `{ id, enabled:true }` 缺 type,validateConfig 会判非法。
2289
+ */
2231
2290
  const gateRuleBody = (rule) => {
2232
2291
  const entry = {
2233
2292
  id: rule.id,
2234
- label: rule.label,
2293
+ label: String(rule.label || rule.id),
2235
2294
  description: rule.description || '',
2236
2295
  severity: rule.severity === 'warn' ? 'warn' : 'error',
2237
2296
  type: rule.type,
2238
2297
  message: rule.message || rule.label || '未通过门禁',
2298
+ enabled: rule.enabled !== false,
2239
2299
  }
2240
2300
  if (Array.isArray(rule.triggers) && rule.triggers.length > 0) entry.triggers = rule.triggers
2241
2301
  if (rule.pattern !== undefined) entry.pattern = rule.pattern
@@ -2244,22 +2304,56 @@ window.__ModuleLoader__.load({
2244
2304
  return entry
2245
2305
  }
2246
2306
 
2307
+ /**
2308
+ * 落盘配置(写当前层)。
2309
+ * - 本层已有的规则原样保留:保存是**整层替换**,漏一条就等于把它删了;
2310
+ * - 只有和「四层合并结果」不同的规则才新建;
2311
+ * - 关掉写 `enabled:false`(完整规则),打开写 `enabled:true`(完整规则);
2312
+ * - 本层原有的 `semantic`(对象或 `false`)没改就原样写回 —— 否则一次只改规则的保存
2313
+ * 会顺手把「语义复审开/关」删掉,改变模型调用边界(Q1-F2)。
2314
+ */
2247
2315
  const gateConfigOf = (scope, draft, data) => {
2248
- const changed = (rule) => {
2249
- const inherited = gateInheritedRule(data, scope, rule.id)
2250
- return !inherited || gateRuleKey(inherited) !== gateRuleKey(rule)
2316
+ const derived = gateDraftOf(data, scope)
2317
+ const baseById = new Map(derived.rules.map((rule) => [rule.id, rule]))
2318
+ const rules = new Map()
2319
+ const layer = gateRawLayer(data, scope)
2320
+ const ownRules = layer && Array.isArray(layer.rules) ? layer.rules : []
2321
+ for (const own of ownRules) {
2322
+ if (!own || !own.id) continue
2323
+ rules.set(own.id, gateRuleBody({ ...own, enabled: own.enabled !== false }))
2324
+ }
2325
+ for (const rule of draft.rules) {
2326
+ const base = baseById.get(rule.id)
2327
+ // 没动过的规则不写:本层没有覆盖就继续跟着下层走。
2328
+ if (base && gateRuleKey(base) === gateRuleKey(rule)) continue
2329
+ rules.set(rule.id, gateRuleBody(rule))
2251
2330
  }
2252
2331
  const config = {
2253
2332
  name: scope === 'user' ? 'user' : 'project',
2254
- rules: draft.rules.filter((rule) => rule.enabled && changed(rule)).map(gateRuleBody),
2333
+ rules: [...rules.values()],
2255
2334
  }
2256
2335
  const base = gateSemanticOf(data, scope)
2257
2336
  const semantic = draft.semantic
2337
+ const rawSemantic = layer && Object.prototype.hasOwnProperty.call(layer, 'semantic') ? layer.semantic : undefined
2338
+ const changed = semantic.enabled !== base.enabled || semantic.model !== base.model || semantic.prompt !== base.prompt
2258
2339
  if (scope === 'project') {
2259
- // 项目层只能关,不能开或换模型(G1 契约):勾上才写 false。
2260
- if (semantic.off && !base.off) config.semantic = false
2261
- } else if (semantic.enabled !== base.enabled || semantic.model !== base.model || semantic.prompt !== base.prompt) {
2262
- config.semantic = { enabled: semantic.enabled, model: semantic.model, prompt: semantic.prompt }
2340
+ // 项目层只能关,不能开或换模型(G1 契约)。
2341
+ if (semantic.off !== base.off) {
2342
+ if (semantic.off) config.semantic = false
2343
+ // 取消勾选「关闭」= 去掉本层覆盖、回到继承:不写 semantic 这一项。
2344
+ } else if (rawSemantic !== undefined) {
2345
+ // 没动过:本层原本写的是什么就原样写回(`false` 或对象)—— 否则一次规则保存
2346
+ // 会让项目层重新开始请求模型(Q1-F2 证据 B)。
2347
+ config.semantic = rawSemantic
2348
+ }
2349
+ } else if (changed) {
2350
+ // 面板改过语义复审:以本层原有的 semantic 对象为底,保留 mode / baseURL / timeout
2351
+ // 这些面板不展示的字段。
2352
+ const baseFields = rawSemantic && typeof rawSemantic === 'object' && !Array.isArray(rawSemantic) ? rawSemantic : {}
2353
+ config.semantic = { ...baseFields, enabled: semantic.enabled, model: semantic.model, prompt: semantic.prompt }
2354
+ } else if (rawSemantic !== undefined) {
2355
+ // 没改语义复审:本层原有的 semantic 原样写回(Q1-F2 证据 A)。
2356
+ config.semantic = rawSemantic
2263
2357
  }
2264
2358
  return config
2265
2359
  }
@@ -2325,9 +2419,20 @@ window.__ModuleLoader__.load({
2325
2419
  const semanticLocked = readOnly || scope === 'project'
2326
2420
  const dirty = !readOnly && JSON.stringify(gateConfigOf(scope, current, data)) !== JSON.stringify(gateConfigOf(scope, derived, data))
2327
2421
  const scopePath = data && data.scopes && data.scopes[scope] ? data.scopes[scope].path : ''
2422
+ // 本层写了 extends 时不能从面板保存:服务端写盘是整层重写,会把 extends 和它共享的
2423
+ // 规则一起冲掉(Q1-F3)。这里明确拒绝并让人去改文件,而不是「保存成功」后规则悄悄消失。
2424
+ const rawLayer = gateRawLayer(data, scope)
2425
+ const layerExtends = Boolean(rawLayer && Object.prototype.hasOwnProperty.call(rawLayer, 'extends'))
2328
2426
 
2329
2427
  async function save() {
2330
2428
  if (!data || readOnly || busy) return
2429
+ if (layerExtends) {
2430
+ setStatus({
2431
+ tone: 'error',
2432
+ text: '保存失败:本层写了 extends(共享规则),面板整层重写会把共享规则冲掉;请直接改配置文件' + (scopePath ? ':' + scopePath : ''),
2433
+ })
2434
+ return
2435
+ }
2331
2436
  setBusy('save')
2332
2437
  setStatus(null)
2333
2438
  try {
@@ -2339,7 +2444,7 @@ window.__ModuleLoader__.load({
2339
2444
  if (notify) notify('门禁配置已保存', 'info')
2340
2445
  await load()
2341
2446
  } catch (error) {
2342
- const text = '保存门禁配置失败:' + String((error && error.message) || error)
2447
+ const text = '保存失败:' + String((error && error.message) || error)
2343
2448
  setStatus({ tone: 'error', text })
2344
2449
  if (notify) notify(text, 'error')
2345
2450
  } finally {
@@ -2358,7 +2463,7 @@ window.__ModuleLoader__.load({
2358
2463
  repo,
2359
2464
  trigger,
2360
2465
  body: sample,
2361
- semantic: current.semantic.enabled && GATE_SEMANTIC_TRIGGERS.includes(trigger),
2466
+ semantic: semanticOn && GATE_SEMANTIC_TRIGGERS.includes(trigger),
2362
2467
  }),
2363
2468
  })
2364
2469
  if (!value || typeof value !== 'object') throw new Error('服务端没有返回预览结果')
@@ -2396,20 +2501,22 @@ window.__ModuleLoader__.load({
2396
2501
  ...current,
2397
2502
  rules: current.rules.map((rule) => (rule.id === id ? { ...rule, enabled: next } : rule)),
2398
2503
  })
2399
- const semanticState = !current.semantic.enabled
2504
+ // 本层显式关闭(off)优先于继承来的 enabled:项目层写 semantic:false 时,
2505
+ // 合并后的 enabled 可能还是上层继承值,不能同屏出现「已关闭 + 当前开启」。
2506
+ const semanticOn = current.semantic.off !== true && current.semantic.enabled === true
2507
+ const semanticState = !semanticOn
2400
2508
  ? '当前关闭:规则照跑,语义复审不发请求。'
2401
2509
  : !current.semantic.model
2402
2510
  ? '开了但没选模型:语义复审会跳过,硬门禁照常。'
2403
2511
  : '当前开启:命中只给提示,不阻断回复。'
2404
2512
  const enabledRules = current.rules.filter((rule) => rule.enabled).length
2405
- // 关掉的规则如果下层也有,本层只能「不覆盖」,停不掉它 —— 卡片上要说清,别让人以为开关失灵。
2406
- const mutedInherited = current.rules.filter((rule) => !rule.enabled && gateInheritedRule(data, scope, rule.id))
2407
2513
 
2408
2514
  return h(Section, { key: 'gate', title: '门禁' },
2409
- h(Hint, null, '内容层检查:只看要发出去的正文,不改工具权限。'),
2515
+ h(Hint, null, '内容层检查:只看要发出去的正文,不改工具权限。关掉一条规则会真正停用,不再参与检查。'),
2410
2516
  h('div', { className: 'dt-field' },
2411
2517
  h('span', { className: 'dt-field-head' }, h('span', null, '作用域')),
2412
2518
  h(SegmentedControl, {
2519
+ id: 'gate-scope',
2413
2520
  options: GATE_SCOPES,
2414
2521
  value: scope,
2415
2522
  label: '门禁作用域',
@@ -2437,6 +2544,9 @@ window.__ModuleLoader__.load({
2437
2544
  data
2438
2545
  ? h('ul', { className: 'dt-rules' }, current.rules.map((rule) => {
2439
2546
  const open = advanced === rule.id
2547
+ const disabledLayer = gateDisabledLayer(data, rule.id)
2548
+ // 停用来自更靠后的层(项目 / 本地):当前作用域写什么都不生效,开关不能假装能改。
2549
+ const lockedByLaterLayer = Boolean(disabledLayer && GATE_LAYER_RANK[disabledLayer] > GATE_LAYER_RANK[scope])
2440
2550
  return h('li', { key: rule.id, className: 'dt-rule' },
2441
2551
  h('div', { className: 'dt-row-main' },
2442
2552
  h('div', { className: 'dt-row-title' },
@@ -2444,8 +2554,16 @@ window.__ModuleLoader__.load({
2444
2554
  h(Tag, { tone: rule.severity === 'warn' ? 'warning' : 'quiet' }, rule.severity === 'warn' ? '提示' : '阻断'),
2445
2555
  gateLayerNames(data, rule.id).map((name) => h(Tag, { key: name, tone: 'outline' }, GATE_LAYER_LABELS[name]))),
2446
2556
  h('div', { className: 'dt-hint' }, rule.description || '没有说明'),
2447
- !rule.enabled && gateInheritedRule(data, scope, rule.id)
2448
- ? h('div', { className: 'dt-hint' }, '这条来自上层:关掉只是本层不覆盖,上层同名规则照旧生效。')
2557
+ !rule.enabled
2558
+ ? h('div', { className: 'dt-hint' }, readOnly
2559
+ ? '已停用:这条规则不参与检查。'
2560
+ : lockedByLaterLayer
2561
+ ? disabledLayer === 'local'
2562
+ ? '本地层(.superagent/gates.local.json,优先级最高)停用了这条:面板改不回来,要恢复请手改这个文件。'
2563
+ : '「' + GATE_LAYER_LABELS[disabledLayer] + '」层比当前作用域更靠后,停用了这条:这里改不回来,请到「' + GATE_LAYER_LABELS[disabledLayer] + '」层处理。'
2564
+ : disabledLayer === scope
2565
+ ? '本层已停用:这条规则不参与检查;打开会把完整规则(含 enabled:true)写回本层。'
2566
+ : '上层已停用:打开会写一条完整规则到本层,把它恢复。')
2449
2567
  : null,
2450
2568
  h(DisclosureRow, {
2451
2569
  title: '高级',
@@ -2472,23 +2590,29 @@ window.__ModuleLoader__.load({
2472
2590
  h(Toggle, {
2473
2591
  id: 'gate-rule-' + rule.id + '-switch',
2474
2592
  checked: rule.enabled,
2475
- disabled: readOnly,
2593
+ disabled: readOnly || lockedByLaterLayer,
2476
2594
  label: '启用「' + rule.label + '」',
2477
2595
  onChange: (next) => toggleRule(rule.id, next),
2478
2596
  })))
2479
2597
  }))
2480
2598
  : null,
2599
+ !readOnly && data && layerExtends
2600
+ ? h('div', { className: 'dt-banner dt-danger' },
2601
+ h('p', { className: 'dt-error', role: 'alert' },
2602
+ '这一层用了 extends(共享规则):面板保存会整层重写并把共享规则冲掉,所以这里不写入。请直接改配置文件:'
2603
+ + (scopePath || '(服务端没有返回路径)')))
2604
+ : null,
2481
2605
  !readOnly && data
2482
2606
  ? h('div', { className: 'dt-savebar' },
2483
2607
  h('p', { className: 'dt-hint', 'aria-live': 'polite' },
2484
- busy === 'save' ? '保存中…' : dirty ? '未保存' : mutedInherited.length > 0 ? '没有要写进本层的改动' : '与已保存的一致'),
2608
+ busy === 'save' ? '保存中…' : layerExtends ? '本层有 extends:保存已禁用' : dirty ? '未保存' : '与已保存的一致'),
2485
2609
  h(Btn, { size: 'sm', variant: 'ghost', disabled: !dirty || Boolean(busy), onClick: () => { setGateDraft(null); setStatus(null) } }, '放弃'),
2486
- h(Btn, { size: 'sm', variant: 'primary', disabled: !dirty || Boolean(busy), onClick: save }, busy === 'save' ? '保存中…' : '保存'))
2610
+ h(Btn, { size: 'sm', variant: 'primary', disabled: !dirty || Boolean(busy) || layerExtends, onClick: save }, busy === 'save' ? '保存中…' : '保存'))
2487
2611
  : null,
2488
2612
  status
2489
2613
  ? h('p', { className: status.tone === 'error' ? 'dt-error' : 'dt-hint', role: status.tone === 'error' ? 'alert' : 'status' }, status.text)
2490
2614
  : null,
2491
- h(Hint, null, '本层只写「和下层不一样」的规则:改过的才会落盘,没动过的继续跟着默认走。关掉一条只表示本层不覆盖,下层同名规则照常生效。'),
2615
+ h(Hint, null, '保存是整层替换:本层已有的覆盖会原样带上,没改过的规则继续跟着下层走。关掉一条会写成 enabled:false 真正停用,重新打开会写成完整规则 + enabled:true。'),
2492
2616
  data
2493
2617
  ? h('div', { className: 'dt-part' },
2494
2618
  h('div', { className: 'dt-subhead' }, h('span', null, '试跑预览')),
@@ -2513,7 +2637,9 @@ window.__ModuleLoader__.load({
2513
2637
  })),
2514
2638
  h('div', { className: 'dt-actions' },
2515
2639
  h(Btn, { size: 'sm', variant: 'outline', disabled: Boolean(busy), onClick: runPreview }, busy === 'preview' ? '预览中…' : '预览'),
2516
- GATE_SEMANTIC_TRIGGERS.includes(trigger) ? h(Tag, { tone: 'info' }, '这类触发会追加语义复审') : null),
2640
+ GATE_SEMANTIC_TRIGGERS.includes(trigger)
2641
+ ? h(Tag, { tone: 'info' }, semanticOn ? '这类触发会追加语义复审' : '这类触发支持语义复审(当前关闭)')
2642
+ : null),
2517
2643
  preview && preview.failed
2518
2644
  ? h('p', { className: 'dt-error', role: 'alert' }, '预览失败:' + preview.failed)
2519
2645
  : preview
package/lib/index.js CHANGED
@@ -55,7 +55,7 @@ import {
55
55
 
56
56
  export const name = 'dsh-session-superagent'
57
57
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
58
- export const SERVER_VERSION = '0.10.7'
58
+ export const SERVER_VERSION = '0.10.8'
59
59
  export const inject = ['tools', 'agents', 'webServer']
60
60
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
61
61
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.10.7",
3
+ "version": "0.10.8",
4
4
  "workspaces": ["packages/*"],
5
5
  "description": "Session-level superagent for DeepSeek Harness: watch a GitHub repository and wake a session when something needs doing. Credentials never reach the model.",
6
6
  "type": "module",
@@ -108,6 +108,6 @@
108
108
  },
109
109
  "dependencies": {
110
110
  "@deepseek-ai/schemastery": "^3.18.5",
111
- "@mycf711/dsh-gate": "0.1.0"
111
+ "@mycf711/dsh-gate": "0.1.1"
112
112
  }
113
113
  }