@dotdance/dsh-skill-scope 0.3.1 → 0.4.1

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.en.md CHANGED
@@ -6,10 +6,10 @@
6
6
  [![npm package](https://img.shields.io/npm/v/%40dotdance%2Fdsh-skill-scope.svg?label=npm%20package)](https://www.npmjs.com/package/@dotdance/dsh-skill-scope)
7
7
  [![npm downloads](https://img.shields.io/npm/dt/%40dotdance%2Fdsh-skill-scope.svg?label=npm%20downloads)](https://www.npmjs.com/package/@dotdance/dsh-skill-scope)
8
8
  [![DSH Web Plugin](https://img.shields.io/badge/DSH%20Web-Plugin-0f766e.svg)](https://github.com/dotdance/dsh-skill-scope)
9
- [![DSH ≥0.2.0-rc.2 <0.3.0](https://img.shields.io/badge/DSH-%E2%89%A5%200.2.0--rc.2%20%3C0.3.0-2563eb.svg)](#installation)
9
+ [![DSH 0.2.2 series](https://img.shields.io/badge/DSH-0.2.2%20series-2563eb.svg)](#installation)
10
10
  ![node](https://img.shields.io/badge/node-%5E22.19.0%20%7C%7C%20%3E%3D24-3c873a.svg)
11
11
 
12
- **One-click toggles for skills and MCP at both global and project scope**
12
+ **Lighten the load on your agent: one-click toggles for skills and MCP, so the context holds only what this turn actually needs. Skills and MCP servers you switch off are no longer injected into the model context — cleaner, and lighter on tokens.**
13
13
 
14
14
  **English** · [简体中文](README.md)
15
15
  </div>
@@ -24,9 +24,6 @@ dsh plugin --profile web add @dotdance/dsh-skill-scope
24
24
 
25
25
  Replace `--profile web` with the name of your own profile.
26
26
 
27
- Requires DSH `≥0.2.0-rc.2` and `<0.3.0` (older hosts do not read `engines.dsh` and judge the plugin incompatible).
28
-
29
-
30
27
  ## The problem it solves
31
28
 
32
29
  The more you install in DSH, the longer the list your agent has to read every turn.
package/README.md CHANGED
@@ -6,10 +6,10 @@
6
6
  [![npm package](https://img.shields.io/npm/v/%40dotdance%2Fdsh-skill-scope.svg?label=npm%20package)](https://www.npmjs.com/package/@dotdance/dsh-skill-scope)
7
7
  [![npm 下载量](https://img.shields.io/npm/dt/%40dotdance%2Fdsh-skill-scope.svg?label=npm%20%E4%B8%8B%E8%BD%BD%E9%87%8F)](https://www.npmjs.com/package/@dotdance/dsh-skill-scope)
8
8
  [![DSH Web Plugin](https://img.shields.io/badge/DSH%20Web-Plugin-0f766e.svg)](https://github.com/dotdance/dsh-skill-scope)
9
- [![DSH ≥0.2.0-rc.2 <0.3.0](https://img.shields.io/badge/DSH-%E2%89%A5%200.2.0--rc.2%20%3C0.3.0-2563eb.svg)](#安装)
9
+ [![DSH 0.2.2 系列](https://img.shields.io/badge/DSH-0.2.2%20%E7%B3%BB%E5%88%97-2563eb.svg)](#安装)
10
10
  ![node](https://img.shields.io/badge/node-%5E22.19.0%20%7C%7C%20%3E%3D24-3c873a.svg)
11
11
 
12
- **全局 + 项目粒度 skill/mcp 一键启停**
12
+ **给你的 Agent 减负:Skill 与 MCP 一键启停,让上下文只装这一轮真正要用的能力。关掉的 skill / MCP 不再进入模型上下文,更干净,更省 token。**
13
13
 
14
14
  [English](README.en.md) · **简体中文**
15
15
  </div>
@@ -24,9 +24,6 @@ dsh plugin --profile web add @dotdance/dsh-skill-scope
24
24
 
25
25
  `--profile web` 换成你自己的 profile 名即可。
26
26
 
27
- 要求 DSH `≥0.2.0-rc.2` 且 `<0.3.0`(更早的宿主不认 `engines.dsh`,会被判为不兼容)。
28
-
29
-
30
27
  ## 它解决什么问题
31
28
 
32
29
  你在 DSH 里装得越多,Agent 每一轮要读的清单就越长。
package/lib/client.js CHANGED
@@ -137,8 +137,8 @@ window.__ModuleLoader__.load({
137
137
  return `网络请求失败:${String(error)}`;
138
138
  }
139
139
  //#endregion
140
- //#region \0dsh-css-module:/home/runner/work/dsh-skill-scope/dsh-skill-scope/src/client/styles.module.css?dsh-css-module
141
- const css = ".Jg-IJa_panel{box-sizing:border-box;flex-direction:column;gap:16px;height:100%;padding:20px 24px 32px;display:flex;overflow-y:auto}.Jg-IJa_overlay{pointer-events:auto;background:var(--dsw-alias-bg-mask-1,#00000073);z-index:60;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.Jg-IJa_modal{z-index:1;background:var(--dsw-alias-bg-layer-1,Canvas);width:min(760px,100vw - 48px);max-width:calc(100vw - 48px);height:min(680px,100vh - 48px);color:var(--dsw-alias-label-primary,CanvasText);border-radius:24px;flex-direction:column;display:flex;position:relative;overflow:hidden;box-shadow:0 24px 64px #00000052}.Jg-IJa_panelHead{flex-direction:column;gap:16px;padding:24px 24px 16px;display:flex}.Jg-IJa_header{justify-content:space-between;align-items:center;gap:12px;display:flex}.Jg-IJa_title{margin:0;font-size:17px;font-weight:600;line-height:1.3}.Jg-IJa_intro{color:var(--dsw-alias-label-secondary,currentColor);margin:0;font-size:13px;line-height:1.55}.Jg-IJa_introWarn{color:var(--dsw-alias-state-warn-primary,currentColor);font-weight:600}.Jg-IJa_closeButton{width:28px;height:28px;color:var(--dsw-alias-label-secondary,currentColor);cursor:pointer;background:0 0;border:0;border-radius:8px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.Jg-IJa_closeButton:hover{background:var(--dsw-alias-interactive-bg-hover,transparent);color:var(--dsw-alias-label-primary,currentColor)}.Jg-IJa_searchRow{align-items:center;display:flex;position:relative}.Jg-IJa_searchIcon{color:var(--dsw-alias-label-tertiary,currentColor);pointer-events:none;display:inline-flex;position:absolute;left:12px}.Jg-IJa_search{border:1px solid var(--dsw-alias-border-l2,currentColor);background:var(--dsw-alias-bg-layer-3,transparent);width:100%;color:var(--dsw-alias-label-primary,currentColor);font:inherit;border-radius:10px;padding:9px 12px 9px 36px;font-size:13px}.Jg-IJa_search::placeholder{color:var(--dsw-alias-label-tertiary,currentColor)}.Jg-IJa_search:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:1px}.Jg-IJa_panelBody{flex:1;min-height:0;padding:4px 24px 24px;overflow-y:auto}.Jg-IJa_body{flex-direction:column;gap:14px;width:100%;display:flex}.Jg-IJa_section{flex-direction:column;gap:10px;min-width:0;display:flex}.Jg-IJa_sectionHead{align-items:center;gap:8px;min-width:0;display:flex}.Jg-IJa_sectionToggle{min-width:0;color:var(--dsw-alias-label-primary,currentColor);font:inherit;cursor:pointer;text-align:left;background:0 0;border:0;flex:1;align-items:center;gap:8px;padding:2px 0;display:flex}.Jg-IJa_sectionTitle{margin:0;font-size:14px;font-weight:600}.Jg-IJa_sectionCount{color:var(--dsw-alias-label-secondary,currentColor);font-size:13px}.Jg-IJa_sectionChevron{color:var(--dsw-alias-label-secondary,currentColor);margin-left:auto;transition:transform .14s;display:inline-flex}.Jg-IJa_sectionChevronOpen{transform:rotate(180deg)}.Jg-IJa_cards{grid-template-columns:repeat(2,minmax(0,1fr));align-items:start;gap:12px;margin:0;padding:0;list-style:none;display:grid}.Jg-IJa_groups{flex-direction:column;gap:14px;display:flex}.Jg-IJa_group{border-left:2px solid var(--dsw-alias-border-1,#00000014);flex-direction:column;gap:8px;min-width:0;padding-left:10px;display:flex}.Jg-IJa_groupToggle{min-width:0;color:var(--dsw-alias-label-secondary,currentColor);font:inherit;cursor:pointer;text-align:left;background:0 0;border:0;align-items:center;gap:6px;padding:2px 0;font-size:13px;font-weight:600;display:flex}.Jg-IJa_groupToggle:hover{color:var(--dsw-alias-label-primary,currentColor)}.Jg-IJa_groupChevron{flex:none;transition:transform .14s;display:inline-flex}.Jg-IJa_groupChevron[data-open=true]{transform:rotate(180deg)}.Jg-IJa_groupTitle{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.Jg-IJa_groupCount{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary,currentColor));font-variant-numeric:tabular-nums;flex:none;font-weight:400}@media (width<=640px){.Jg-IJa_cards{grid-template-columns:minmax(0,1fr)}}.Jg-IJa_card{border:1px solid var(--dsw-alias-border-l2,currentColor);background:var(--dsw-alias-bg-layer-3,transparent);border-radius:10px;min-width:0;overflow:hidden}.Jg-IJa_cardHead{align-items:center;gap:10px;min-width:0;padding:11px 12px;display:flex}.Jg-IJa_cardMain{flex:1;align-items:center;gap:10px;min-width:0;display:flex}.Jg-IJa_cardName{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:13px;font-weight:600;overflow:hidden}.Jg-IJa_overridden{align-items:center;display:inline-flex}.Jg-IJa_cardDisabled .Jg-IJa_cardName{color:var(--dsw-alias-label-secondary,currentColor)}.Jg-IJa_cardTail{flex:0 3 auto;align-items:center;gap:6px;min-width:0;display:inline-flex}.Jg-IJa_expandButton{width:20px;height:20px;color:var(--dsw-alias-label-secondary,currentColor);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.Jg-IJa_expandButton:hover{background:var(--dsw-alias-interactive-bg-hover,transparent)}.Jg-IJa_expandChevron{transition:transform .14s;display:inline-flex}.Jg-IJa_expandChevronOpen{transform:rotate(180deg)}.Jg-IJa_cardBody{border-top:1px solid var(--dsw-alias-border-l2,currentColor);color:var(--dsw-alias-label-secondary,currentColor);padding:10px;font-size:12px;line-height:1.55}.Jg-IJa_cardDescription{overflow-wrap:anywhere;margin:0}.Jg-IJa_detailRow{gap:10px;margin-top:8px;display:flex}.Jg-IJa_detailKey{width:56px;color:var(--dsw-alias-label-secondary,currentColor);flex:none}.Jg-IJa_detailValue{min-width:0;color:var(--dsw-alias-label-primary,currentColor);overflow-wrap:anywhere}.Jg-IJa_detailOrigin{min-width:0;color:var(--dsw-alias-label-primary,currentColor);overflow-wrap:anywhere;word-break:break-all;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:1.5}.Jg-IJa_toolList{min-width:0;max-height:120px;margin:0;padding:0;list-style:none;overflow-y:auto}.Jg-IJa_toolName{color:var(--dsw-alias-label-primary,currentColor);overflow-wrap:anywhere;word-break:break-all;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.Jg-IJa_switch{cursor:pointer;background:0 0;border:0;border-radius:999px;flex:none;align-items:center;padding:0;display:inline-flex}.Jg-IJa_switch:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,currentColor);outline-offset:2px}.Jg-IJa_switchTrack{background:var(--dsw-alias-border-l2,currentColor);border-radius:999px;width:28px;height:16px;transition:background-color .12s ease-in-out;display:inline-block;position:relative}.Jg-IJa_switchOn .Jg-IJa_switchTrack{background:var(--dsw-alias-state-business-primary,currentColor)}.Jg-IJa_switchThumb{background:var(--dsw-alias-bg-layer-1,currentColor);border-radius:50%;width:12px;height:12px;transition:transform .12s ease-in-out;position:absolute;top:2px;left:2px}.Jg-IJa_switchOn .Jg-IJa_switchThumb{transform:translate(12px)}.Jg-IJa_switch:disabled{cursor:not-allowed;opacity:.5}.Jg-IJa_alert{border:1px solid var(--dsw-alias-state-error-primary,currentColor);color:var(--dsw-alias-state-error-primary,currentColor);border-radius:8px;justify-content:space-between;align-items:center;gap:8px;padding:8px 10px;font-size:12px;display:flex}.Jg-IJa_modeRow{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.Jg-IJa_modeButton{border:1px solid var(--dsw-alias-border-l2,currentColor);color:var(--dsw-alias-label-secondary,currentColor);font:inherit;cursor:pointer;background:0 0;border-radius:999px;padding:4px 12px;font-size:12px}.Jg-IJa_modeButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,transparent)}.Jg-IJa_modeButtonActive{border-color:var(--dsw-alias-brand-primary,currentColor);background:var(--dsw-alias-interactive-bg-active,transparent);color:var(--dsw-alias-brand-primary,currentColor)}.Jg-IJa_modeButton:disabled{cursor:not-allowed;opacity:.5}.Jg-IJa_modeRowTrailing{align-items:center;margin-left:auto;display:flex}.Jg-IJa_toggleRow{color:var(--dsw-alias-label-secondary,currentColor);align-items:center;gap:8px;font-size:12px;display:flex}.Jg-IJa_toggleLabel{cursor:default;user-select:none}.Jg-IJa_button{border:1px solid var(--dsw-alias-border-l2,currentColor);color:var(--dsw-alias-label-secondary,currentColor);font:inherit;cursor:pointer;background:0 0;border-radius:8px;padding:4px 10px;font-size:12px}.Jg-IJa_button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,transparent)}.Jg-IJa_button:disabled{cursor:not-allowed;opacity:.5}.Jg-IJa_empty{color:var(--dsw-alias-label-secondary,currentColor);padding:4px 2px;font-size:12px}.Jg-IJa_chip{border:1px solid var(--dsw-alias-border-l2,currentColor);color:var(--dsw-alias-label-secondary,currentColor);font:inherit;cursor:pointer;background:0 0;border-radius:999px;align-items:center;gap:5px;padding:3px 9px;font-size:12px;display:inline-flex}.Jg-IJa_chip:hover{background:var(--dsw-alias-interactive-bg-hover,transparent)}";
140
+ //#region \0dsh-css-module:/Users/go/proj/dsh-skill-scope/src/client/styles.module.css?dsh-css-module
141
+ const css = ".p4Fk8G_panel{box-sizing:border-box;flex-direction:column;gap:16px;height:100%;padding:20px 24px 32px;display:flex;overflow-y:auto}.p4Fk8G_overlay{pointer-events:auto;background:var(--dsw-alias-bg-mask-1,#00000073);z-index:60;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.p4Fk8G_modal{z-index:1;background:var(--dsw-alias-bg-layer-1,Canvas);width:min(760px,100vw - 48px);max-width:calc(100vw - 48px);height:min(680px,100vh - 48px);color:var(--dsw-alias-label-primary,CanvasText);border-radius:24px;flex-direction:column;display:flex;position:relative;overflow:hidden;box-shadow:0 24px 64px #00000052}.p4Fk8G_panelHead{flex-direction:column;gap:16px;padding:24px 24px 16px;display:flex}.p4Fk8G_header{justify-content:space-between;align-items:center;gap:12px;display:flex}.p4Fk8G_title{margin:0;font-size:17px;font-weight:600;line-height:1.3}.p4Fk8G_intro{color:var(--dsw-alias-label-secondary,currentColor);margin:0;font-size:13px;line-height:1.55}.p4Fk8G_introWarn{color:var(--dsw-alias-state-warn-primary,currentColor);font-weight:600}.p4Fk8G_closeButton{width:28px;height:28px;color:var(--dsw-alias-label-secondary,currentColor);cursor:pointer;background:0 0;border:0;border-radius:8px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.p4Fk8G_closeButton:hover{background:var(--dsw-alias-interactive-bg-hover,transparent);color:var(--dsw-alias-label-primary,currentColor)}.p4Fk8G_searchRow{align-items:center;display:flex;position:relative}.p4Fk8G_searchIcon{color:var(--dsw-alias-label-tertiary,currentColor);pointer-events:none;display:inline-flex;position:absolute;left:12px}.p4Fk8G_search{border:1px solid var(--dsw-alias-border-l2,currentColor);background:var(--dsw-alias-bg-layer-3,transparent);width:100%;color:var(--dsw-alias-label-primary,currentColor);font:inherit;border-radius:10px;padding:9px 12px 9px 36px;font-size:13px}.p4Fk8G_search::placeholder{color:var(--dsw-alias-label-tertiary,currentColor)}.p4Fk8G_search:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:1px}.p4Fk8G_panelBody{flex:1;min-height:0;padding:4px 24px 24px;overflow-y:auto}.p4Fk8G_body{flex-direction:column;gap:14px;width:100%;display:flex}.p4Fk8G_section{flex-direction:column;gap:10px;min-width:0;display:flex}.p4Fk8G_sectionHead{align-items:center;gap:8px;min-width:0;display:flex}.p4Fk8G_sectionToggle{min-width:0;color:var(--dsw-alias-label-primary,currentColor);font:inherit;cursor:pointer;text-align:left;background:0 0;border:0;flex:1;align-items:center;gap:8px;padding:2px 0;display:flex}.p4Fk8G_sectionTitle{margin:0;font-size:14px;font-weight:600}.p4Fk8G_sectionCount{color:var(--dsw-alias-label-secondary,currentColor);font-size:13px}.p4Fk8G_sectionChevron{color:var(--dsw-alias-label-secondary,currentColor);margin-left:auto;transition:transform .14s;display:inline-flex}.p4Fk8G_sectionChevronOpen{transform:rotate(180deg)}.p4Fk8G_cards{grid-template-columns:repeat(2,minmax(0,1fr));align-items:start;gap:12px;margin:0;padding:0;list-style:none;display:grid}.p4Fk8G_groups{flex-direction:column;gap:14px;display:flex}.p4Fk8G_group{border-left:2px solid var(--dsw-alias-border-1,#00000014);flex-direction:column;gap:8px;min-width:0;padding-left:10px;display:flex}.p4Fk8G_groupToggle{min-width:0;color:var(--dsw-alias-label-secondary,currentColor);font:inherit;cursor:pointer;text-align:left;background:0 0;border:0;align-items:center;gap:6px;padding:2px 0;font-size:13px;font-weight:600;display:flex}.p4Fk8G_groupToggle:hover{color:var(--dsw-alias-label-primary,currentColor)}.p4Fk8G_groupChevron{flex:none;transition:transform .14s;display:inline-flex}.p4Fk8G_groupChevron[data-open=true]{transform:rotate(180deg)}.p4Fk8G_groupTitle{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.p4Fk8G_groupCount{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary,currentColor));font-variant-numeric:tabular-nums;flex:none;font-weight:400}@media (width<=640px){.p4Fk8G_cards{grid-template-columns:minmax(0,1fr)}}.p4Fk8G_card{border:1px solid var(--dsw-alias-border-l2,currentColor);background:var(--dsw-alias-bg-layer-3,transparent);border-radius:10px;min-width:0;overflow:hidden}.p4Fk8G_cardHead{align-items:center;gap:10px;min-width:0;padding:11px 12px;display:flex}.p4Fk8G_cardMain{flex:1;align-items:center;gap:10px;min-width:0;display:flex}.p4Fk8G_cardName{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:13px;font-weight:600;overflow:hidden}.p4Fk8G_overridden{align-items:center;display:inline-flex}.p4Fk8G_cardDisabled .p4Fk8G_cardName{color:var(--dsw-alias-label-secondary,currentColor)}.p4Fk8G_cardTail{flex:0 3 auto;align-items:center;gap:6px;min-width:0;display:inline-flex}.p4Fk8G_expandButton{width:20px;height:20px;color:var(--dsw-alias-label-secondary,currentColor);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.p4Fk8G_expandButton:hover{background:var(--dsw-alias-interactive-bg-hover,transparent)}.p4Fk8G_expandChevron{transition:transform .14s;display:inline-flex}.p4Fk8G_expandChevronOpen{transform:rotate(180deg)}.p4Fk8G_cardBody{border-top:1px solid var(--dsw-alias-border-l2,currentColor);color:var(--dsw-alias-label-secondary,currentColor);padding:10px;font-size:12px;line-height:1.55}.p4Fk8G_cardDescription{overflow-wrap:anywhere;margin:0}.p4Fk8G_detailRow{gap:10px;margin-top:8px;display:flex}.p4Fk8G_detailKey{width:56px;color:var(--dsw-alias-label-secondary,currentColor);flex:none}.p4Fk8G_detailValue{min-width:0;color:var(--dsw-alias-label-primary,currentColor);overflow-wrap:anywhere}.p4Fk8G_detailOrigin{min-width:0;color:var(--dsw-alias-label-primary,currentColor);overflow-wrap:anywhere;word-break:break-all;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:1.5}.p4Fk8G_toolList{min-width:0;max-height:120px;margin:0;padding:0;list-style:none;overflow-y:auto}.p4Fk8G_toolName{color:var(--dsw-alias-label-primary,currentColor);overflow-wrap:anywhere;word-break:break-all;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.p4Fk8G_switch{cursor:pointer;background:0 0;border:0;border-radius:999px;flex:none;align-items:center;padding:0;display:inline-flex}.p4Fk8G_switch:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary,currentColor);outline-offset:2px}.p4Fk8G_switchTrack{background:var(--dsw-alias-border-l2,currentColor);border-radius:999px;width:28px;height:16px;transition:background-color .12s ease-in-out;display:inline-block;position:relative}.p4Fk8G_switchOn .p4Fk8G_switchTrack{background:var(--dsw-alias-state-business-primary,currentColor)}.p4Fk8G_switchThumb{background:var(--dsw-alias-bg-layer-1,currentColor);border-radius:50%;width:12px;height:12px;transition:transform .12s ease-in-out;position:absolute;top:2px;left:2px}.p4Fk8G_switchOn .p4Fk8G_switchThumb{transform:translate(12px)}.p4Fk8G_switch:disabled{cursor:not-allowed;opacity:.5}.p4Fk8G_alert{border:1px solid var(--dsw-alias-state-error-primary,currentColor);color:var(--dsw-alias-state-error-primary,currentColor);border-radius:8px;justify-content:space-between;align-items:center;gap:8px;padding:8px 10px;font-size:12px;display:flex}.p4Fk8G_modeRow{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.p4Fk8G_modeButton{border:1px solid var(--dsw-alias-border-l2,currentColor);color:var(--dsw-alias-label-secondary,currentColor);font:inherit;cursor:pointer;background:0 0;border-radius:999px;padding:4px 12px;font-size:12px}.p4Fk8G_modeButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,transparent)}.p4Fk8G_modeButtonActive{border-color:var(--dsw-alias-brand-primary,currentColor);background:var(--dsw-alias-interactive-bg-active,transparent);color:var(--dsw-alias-brand-primary,currentColor)}.p4Fk8G_modeButton:disabled{cursor:not-allowed;opacity:.5}.p4Fk8G_modeRowTrailing{align-items:center;margin-left:auto;display:flex}.p4Fk8G_toggleRow{color:var(--dsw-alias-label-secondary,currentColor);align-items:center;gap:8px;font-size:12px;display:flex}.p4Fk8G_toggleLabel{cursor:default;user-select:none}.p4Fk8G_button{border:1px solid var(--dsw-alias-border-l2,currentColor);color:var(--dsw-alias-label-secondary,currentColor);font:inherit;cursor:pointer;background:0 0;border-radius:8px;padding:4px 10px;font-size:12px}.p4Fk8G_button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,transparent)}.p4Fk8G_button:disabled{cursor:not-allowed;opacity:.5}.p4Fk8G_empty{color:var(--dsw-alias-label-secondary,currentColor);padding:4px 2px;font-size:12px}.p4Fk8G_chip{border:1px solid var(--dsw-alias-border-l2,currentColor);color:var(--dsw-alias-label-secondary,currentColor);font:inherit;cursor:pointer;background:0 0;border-radius:999px;align-items:center;gap:5px;padding:3px 9px;font-size:12px;display:inline-flex}.p4Fk8G_chip:hover{background:var(--dsw-alias-interactive-bg-hover,transparent)}";
142
142
  const tagId = "@dotdance/dsh-skill-scope/styles.module.css";
143
143
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
144
144
  const tag = document.createElement("style");
@@ -148,66 +148,66 @@ window.__ModuleLoader__.load({
148
148
  document.head.appendChild(tag);
149
149
  }
150
150
  var styles_module_default = {
151
- "cards": "Jg-IJa_cards",
152
- "toggleLabel": "Jg-IJa_toggleLabel",
153
- "alert": "Jg-IJa_alert",
154
- "button": "Jg-IJa_button",
155
- "panel": "Jg-IJa_panel",
156
- "modeButtonActive": "Jg-IJa_modeButtonActive",
157
- "cardDisabled": "Jg-IJa_cardDisabled",
158
- "toggleRow": "Jg-IJa_toggleRow",
159
- "cardBody": "Jg-IJa_cardBody",
160
- "toolList": "Jg-IJa_toolList",
161
- "searchIcon": "Jg-IJa_searchIcon",
162
- "sectionCount": "Jg-IJa_sectionCount",
163
- "detailRow": "Jg-IJa_detailRow",
164
- "modeButton": "Jg-IJa_modeButton",
165
- "sectionHead": "Jg-IJa_sectionHead",
166
- "toolName": "Jg-IJa_toolName",
167
- "intro": "Jg-IJa_intro",
168
- "card": "Jg-IJa_card",
169
- "groupCount": "Jg-IJa_groupCount",
170
- "section": "Jg-IJa_section",
171
- "panelHead": "Jg-IJa_panelHead",
172
- "cardMain": "Jg-IJa_cardMain",
173
- "cardDescription": "Jg-IJa_cardDescription",
174
- "groupToggle": "Jg-IJa_groupToggle",
175
- "detailValue": "Jg-IJa_detailValue",
176
- "panelBody": "Jg-IJa_panelBody",
177
- "title": "Jg-IJa_title",
178
- "overridden": "Jg-IJa_overridden",
179
- "chip": "Jg-IJa_chip",
180
- "groupTitle": "Jg-IJa_groupTitle",
181
- "expandButton": "Jg-IJa_expandButton",
182
- "overlay": "Jg-IJa_overlay",
183
- "switchTrack": "Jg-IJa_switchTrack",
184
- "expandChevronOpen": "Jg-IJa_expandChevronOpen",
185
- "sectionTitle": "Jg-IJa_sectionTitle",
186
- "body": "Jg-IJa_body",
187
- "sectionChevronOpen": "Jg-IJa_sectionChevronOpen",
188
- "modal": "Jg-IJa_modal",
189
- "empty": "Jg-IJa_empty",
190
- "header": "Jg-IJa_header",
191
- "search": "Jg-IJa_search",
192
- "switch": "Jg-IJa_switch",
193
- "searchRow": "Jg-IJa_searchRow",
194
- "modeRow": "Jg-IJa_modeRow",
195
- "expandChevron": "Jg-IJa_expandChevron",
196
- "cardName": "Jg-IJa_cardName",
197
- "introWarn": "Jg-IJa_introWarn",
198
- "group": "Jg-IJa_group",
199
- "groupChevron": "Jg-IJa_groupChevron",
200
- "modeRowTrailing": "Jg-IJa_modeRowTrailing",
201
- "switchOn": "Jg-IJa_switchOn",
202
- "switchThumb": "Jg-IJa_switchThumb",
203
- "groups": "Jg-IJa_groups",
204
- "detailOrigin": "Jg-IJa_detailOrigin",
205
- "sectionChevron": "Jg-IJa_sectionChevron",
206
- "sectionToggle": "Jg-IJa_sectionToggle",
207
- "cardTail": "Jg-IJa_cardTail",
208
- "cardHead": "Jg-IJa_cardHead",
209
- "detailKey": "Jg-IJa_detailKey",
210
- "closeButton": "Jg-IJa_closeButton"
151
+ "overlay": "p4Fk8G_overlay",
152
+ "sectionToggle": "p4Fk8G_sectionToggle",
153
+ "closeButton": "p4Fk8G_closeButton",
154
+ "toggleLabel": "p4Fk8G_toggleLabel",
155
+ "expandChevronOpen": "p4Fk8G_expandChevronOpen",
156
+ "title": "p4Fk8G_title",
157
+ "sectionChevron": "p4Fk8G_sectionChevron",
158
+ "sectionChevronOpen": "p4Fk8G_sectionChevronOpen",
159
+ "searchRow": "p4Fk8G_searchRow",
160
+ "groupChevron": "p4Fk8G_groupChevron",
161
+ "switchThumb": "p4Fk8G_switchThumb",
162
+ "section": "p4Fk8G_section",
163
+ "panelBody": "p4Fk8G_panelBody",
164
+ "intro": "p4Fk8G_intro",
165
+ "cardDisabled": "p4Fk8G_cardDisabled",
166
+ "cardDescription": "p4Fk8G_cardDescription",
167
+ "detailValue": "p4Fk8G_detailValue",
168
+ "button": "p4Fk8G_button",
169
+ "panel": "p4Fk8G_panel",
170
+ "cards": "p4Fk8G_cards",
171
+ "introWarn": "p4Fk8G_introWarn",
172
+ "chip": "p4Fk8G_chip",
173
+ "cardName": "p4Fk8G_cardName",
174
+ "cardTail": "p4Fk8G_cardTail",
175
+ "searchIcon": "p4Fk8G_searchIcon",
176
+ "toggleRow": "p4Fk8G_toggleRow",
177
+ "card": "p4Fk8G_card",
178
+ "detailOrigin": "p4Fk8G_detailOrigin",
179
+ "header": "p4Fk8G_header",
180
+ "expandButton": "p4Fk8G_expandButton",
181
+ "toolName": "p4Fk8G_toolName",
182
+ "cardBody": "p4Fk8G_cardBody",
183
+ "cardMain": "p4Fk8G_cardMain",
184
+ "expandChevron": "p4Fk8G_expandChevron",
185
+ "alert": "p4Fk8G_alert",
186
+ "panelHead": "p4Fk8G_panelHead",
187
+ "toolList": "p4Fk8G_toolList",
188
+ "modeRow": "p4Fk8G_modeRow",
189
+ "groupCount": "p4Fk8G_groupCount",
190
+ "body": "p4Fk8G_body",
191
+ "switch": "p4Fk8G_switch",
192
+ "modeButtonActive": "p4Fk8G_modeButtonActive",
193
+ "modal": "p4Fk8G_modal",
194
+ "groups": "p4Fk8G_groups",
195
+ "empty": "p4Fk8G_empty",
196
+ "switchOn": "p4Fk8G_switchOn",
197
+ "groupToggle": "p4Fk8G_groupToggle",
198
+ "group": "p4Fk8G_group",
199
+ "modeRowTrailing": "p4Fk8G_modeRowTrailing",
200
+ "sectionTitle": "p4Fk8G_sectionTitle",
201
+ "groupTitle": "p4Fk8G_groupTitle",
202
+ "detailRow": "p4Fk8G_detailRow",
203
+ "detailKey": "p4Fk8G_detailKey",
204
+ "modeButton": "p4Fk8G_modeButton",
205
+ "search": "p4Fk8G_search",
206
+ "overridden": "p4Fk8G_overridden",
207
+ "sectionHead": "p4Fk8G_sectionHead",
208
+ "switchTrack": "p4Fk8G_switchTrack",
209
+ "sectionCount": "p4Fk8G_sectionCount",
210
+ "cardHead": "p4Fk8G_cardHead"
211
211
  };
212
212
  //#endregion
213
213
  //#region src/client/parts.tsx
@@ -988,8 +988,8 @@ window.__ModuleLoader__.load({
988
988
  /**
989
989
  * 加载 + 三件改动操作。
990
990
  *
991
- * 回滚依赖**提交时刻捕获的快照**,不是 `value` 的闭包 —— 后者在连续快速点击时会拿到
992
- * 过期的值,回滚到更早的状态。提交串行化(`chain`),避免并发写入互相覆盖。
991
+ * 保存时从最近一次成功的服务端状态重算操作;成功后重放尚未发送的操作,
992
+ * 失败则取消本批剩余操作并回滚到最近确认的状态。
993
993
  */
994
994
  function usePolicyPanel({ load, save, toggle: applyToggle, mergeSaved }) {
995
995
  const [value, setValue] = (0, react.useState)(null);
@@ -998,20 +998,46 @@ window.__ModuleLoader__.load({
998
998
  const [loadFailed, setLoadFailed] = (0, react.useState)(false);
999
999
  const [view, setView] = (0, react.useState)("all");
1000
1000
  const [query, setQuery] = (0, react.useState)("");
1001
+ const confirmed = (0, react.useRef)(null);
1002
+ const pending = (0, react.useRef)([]);
1003
+ const running = (0, react.useRef)(false);
1004
+ const refreshPending = (0, react.useRef)(false);
1005
+ const saveFailed = (0, react.useRef)(false);
1006
+ const generation = (0, react.useRef)(0);
1007
+ const valueRef = (0, react.useRef)(null);
1001
1008
  const alive = (0, react.useRef)(true);
1002
1009
  const [nonce, setNonce] = (0, react.useState)(0);
1003
- (0, react.useEffect)(() => () => {
1004
- alive.current = false;
1010
+ (0, react.useEffect)(() => {
1011
+ alive.current = true;
1012
+ return () => {
1013
+ alive.current = false;
1014
+ };
1005
1015
  }, []);
1006
1016
  const refresh = (0, react.useCallback)(async () => {
1017
+ if (!alive.current) return;
1018
+ if (running.current) {
1019
+ refreshPending.current = true;
1020
+ return;
1021
+ }
1007
1022
  setNonce((n) => n + 1);
1008
1023
  }, []);
1009
1024
  (0, react.useEffect)(() => {
1025
+ if (running.current) {
1026
+ refreshPending.current = true;
1027
+ return;
1028
+ }
1010
1029
  let current = true;
1030
+ const startedAt = generation.current;
1011
1031
  setError(null);
1012
1032
  setLoadFailed(false);
1013
1033
  load().then((loaded) => {
1014
1034
  if (current && alive.current) {
1035
+ if (startedAt !== generation.current) {
1036
+ if (!saveFailed.current) refresh();
1037
+ return;
1038
+ }
1039
+ confirmed.current = loaded;
1040
+ valueRef.current = loaded;
1015
1041
  setValue(loaded);
1016
1042
  setLoadFailed(false);
1017
1043
  }
@@ -1024,31 +1050,73 @@ window.__ModuleLoader__.load({
1024
1050
  return () => {
1025
1051
  current = false;
1026
1052
  };
1027
- }, [nonce, load]);
1028
- const chain = (0, react.useRef)(Promise.resolve());
1029
- const valueRef = (0, react.useRef)(null);
1030
- valueRef.current = value;
1053
+ }, [
1054
+ nonce,
1055
+ load,
1056
+ refresh
1057
+ ]);
1058
+ const publish = (0, react.useCallback)((next) => {
1059
+ valueRef.current = next;
1060
+ if (alive.current) setValue(next);
1061
+ }, []);
1031
1062
  const commit = (0, react.useCallback)(async (mutate) => {
1032
1063
  const current = valueRef.current;
1033
- if (current === null) return;
1064
+ if (current === null || !alive.current) return false;
1034
1065
  const next = mutate(current);
1035
- if (next === null) return;
1036
- setValue(next);
1066
+ if (next === null) return true;
1067
+ generation.current++;
1068
+ publish(next);
1037
1069
  setBusy(true);
1038
- const snapshot = current;
1039
- chain.current = chain.current.then(() => save(snapshot, next)).then((saved) => {
1040
- if (!alive.current) return;
1041
- setValue((prev) => prev === null ? prev : mergeSaved === void 0 ? saved : mergeSaved(prev, saved));
1042
- setError(null);
1043
- }, (cause) => {
1044
- if (!alive.current) return;
1045
- setValue(snapshot);
1046
- setError(describeError(cause));
1047
- }).finally(() => {
1048
- if (alive.current) setBusy(false);
1049
- });
1050
- return chain.current;
1051
- }, [save, mergeSaved]);
1070
+ const completion = new Promise((done) => pending.current.push({
1071
+ mutate,
1072
+ done
1073
+ }));
1074
+ if (!running.current) {
1075
+ running.current = true;
1076
+ (async () => {
1077
+ try {
1078
+ while (pending.current.length > 0) {
1079
+ const operation = pending.current[0];
1080
+ if (operation === void 0) break;
1081
+ const base = confirmed.current ?? current;
1082
+ const target = operation.mutate(base);
1083
+ if (target !== null) {
1084
+ const saved = await save(base, target);
1085
+ confirmed.current = mergeSaved === void 0 ? saved : mergeSaved(target, saved);
1086
+ }
1087
+ saveFailed.current = false;
1088
+ pending.current.shift();
1089
+ operation.done(true);
1090
+ let preview = confirmed.current ?? base;
1091
+ for (const queued of pending.current) preview = queued.mutate(preview) ?? preview;
1092
+ publish(preview);
1093
+ if (alive.current) setError(null);
1094
+ }
1095
+ } catch (cause) {
1096
+ refreshPending.current = false;
1097
+ saveFailed.current = true;
1098
+ const cancelled = pending.current.splice(0);
1099
+ publish(confirmed.current ?? current);
1100
+ if (alive.current) setError(describeError(cause));
1101
+ for (const operation of cancelled) operation.done(false);
1102
+ } finally {
1103
+ running.current = false;
1104
+ if (alive.current) {
1105
+ setBusy(false);
1106
+ if (refreshPending.current) {
1107
+ refreshPending.current = false;
1108
+ setNonce((n) => n + 1);
1109
+ }
1110
+ }
1111
+ }
1112
+ })();
1113
+ }
1114
+ return completion;
1115
+ }, [
1116
+ save,
1117
+ mergeSaved,
1118
+ publish
1119
+ ]);
1052
1120
  return {
1053
1121
  value,
1054
1122
  error,
@@ -1215,7 +1283,8 @@ window.__ModuleLoader__.load({
1215
1283
  * 会把服务端模块拖进浏览器包。
1216
1284
  */
1217
1285
  function isOpen(value, which, name) {
1218
- return value.workspace[which][name] ?? isEnabled(value.global[which], name);
1286
+ const local = value.workspace[which];
1287
+ return (Object.hasOwn(local, name) ? local[name] : void 0) ?? isEnabled(value.global[which], name);
1219
1288
  }
1220
1289
  /**
1221
1290
  * 是否「与全局不同」——**只由这一个条件决定**(用户明确要求)。
@@ -1225,7 +1294,8 @@ window.__ModuleLoader__.load({
1225
1294
  * 表里有键且与全局反向 ⇒ 是差异 ⇒ 标红。
1226
1295
  */
1227
1296
  function isOverridden(value, which, name) {
1228
- const local = value.workspace[which][name];
1297
+ const map = value.workspace[which];
1298
+ const local = Object.hasOwn(map, name) ? map[name] : void 0;
1229
1299
  return local !== void 0 && local !== isEnabled(value.global[which], name);
1230
1300
  }
1231
1301
  /** 取工程名:`cwd` 的 basename。用 `/` 与 `\` 都切,避免宿主报一个 Windows 路径时整条标题变成完整路径。 */
@@ -1277,9 +1347,11 @@ window.__ModuleLoader__.load({
1277
1347
  */
1278
1348
  const toggle = (0, react.useCallback)((current, which, name, open) => {
1279
1349
  const base = isEnabled(current.global[which], name);
1280
- const next = { ...current.workspace[which] };
1350
+ const next = {
1351
+ ...current.workspace[which],
1352
+ [name]: open
1353
+ };
1281
1354
  if (open === base) delete next[name];
1282
- else next[name] = open;
1283
1355
  return {
1284
1356
  ...current,
1285
1357
  workspace: {
@@ -1314,7 +1386,9 @@ window.__ModuleLoader__.load({
1314
1386
  ...current.global,
1315
1387
  showOfficialSkills: open
1316
1388
  }
1317
- }).then(() => panel.refresh());
1389
+ }).then((saved) => {
1390
+ if (saved) return panel.refresh();
1391
+ });
1318
1392
  }, [panel.commit, panel.refresh]);
1319
1393
  const refresh = () => {
1320
1394
  panel.refresh();
@@ -1479,19 +1553,19 @@ window.__ModuleLoader__.load({
1479
1553
  };
1480
1554
  };
1481
1555
  const readOpen = () => open;
1482
- /** 会话 id 在渲染期由槽位标准 props 给出,注册期还没有;用可变引用承接。 */
1556
+ /** 最近一次被点击的会话 id;不能在 chip 渲染时写入,否则多个会话会互相覆盖。 */
1483
1557
  let sessionId;
1484
1558
  ctx.slots.inject("conversation.input.right", () => ctx.slots.register({
1485
1559
  name: "conversation.input.right",
1486
1560
  id: WORKSPACE_CHIP_ID,
1487
1561
  order: 30
1488
1562
  }, ((props) => {
1489
- sessionId = props.sessionId;
1490
1563
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkspaceChip, {
1491
1564
  hasSession: typeof props.sessionId === "string" && props.sessionId !== "",
1492
1565
  t,
1493
1566
  ...props.useSession === void 0 ? {} : { useSession: props.useSession },
1494
1567
  onOpen: () => {
1568
+ sessionId = props.sessionId;
1495
1569
  open = true;
1496
1570
  notify();
1497
1571
  }