dsh-mcp-skills-controller 0.1.1 → 0.2.0

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 CHANGED
@@ -8,7 +8,8 @@ DeepSeek Harness (DSH) 插件:用「全局持久化默认 + 会话级覆盖」
8
8
 
9
9
  - **全局默认**:在设置页逐项设置 MCP 服务器与 skill 的默认开关,重启后保留,影响之后新建的会话。
10
10
  - **会话覆盖**:会话标题栏与新建会话页各有 MCP / Skills 两个按钮。每行可在「开 / 关」之间切换;有会话覆盖时出现 ↺,点击即可恢复跟随全局。切换只影响当前会话。
11
- - **设置页详情**:点击设置页的行(开关本身除外)可展开详情——MCP 服务器显示当前注册的工具名,skill 显示描述、来源与指令文件位置,并可一键打开所在目录。
11
+ - **设置页详情**:点击设置页的行(开关本身除外)可展开详情——MCP 服务器显示当前注册的工具名,skill 显示描述、来源与指令文件位置,并可一键打开所在目录;打包在 `app.asar` 内的技能没有可打开的本地目录,只显示路径。
12
+ - **skills 来源分组**:设置页的 skills 按「用户 / 插件 / 预设 / 其他」分组,每组带一个三态开关(开 / 关 / 部分开启)。分组依据 DSH 的来源标签:用户根、项目根、随包 skill、`customSkillDirs` 配置挂载、运行时注册,以及无法识别的第三方来源;预设 = 随包 + 配置挂载。
12
13
  - **项目级 skills**:DSH 从项目根(最近的 `.git` 祖先目录)的 `.dsh/skills`、`.agents/skills` 发现的技能,只出现在会话级的 Skills 按钮里,默认开启、不受全局默认影响;可以在会话内单独关闭。设置页不列出它们,全局批量操作也不会影响。
13
14
  - **子代理独立**:每个子代理按自己的会话覆盖与当前全局默认计算,不继承父会话的覆盖。
14
15
  - **可逆**:不改写 DSH 配置文件或 `SKILL.md`;卸载插件后状态文件残留无害。
@@ -23,7 +24,7 @@ DeepSeek Harness (DSH) 插件:用「全局持久化默认 + 会话级覆盖」
23
24
 
24
25
  ## 使用
25
26
 
26
- - **设置全局默认**:打开设置中的「MCP & Skills」区块。MCP 与 Skills 各一张表,逐项开关或使用表头的整组按钮。点击行可展开详情。
27
+ - **设置全局默认**:打开设置中的「MCP & Skills」区块。MCP 与 Skills 各一张表,逐项开关;区块头和 skills 分组头都是三态开关(开 / 关 / 部分开启),与条目开关右缘对齐。点击行可展开详情。
27
28
  - **调整当前会话**:点击会话标题栏(或新会话页输入框上方)的 **MCP** / **Skills** 按钮。逐项切换,或用表头的「跟随全局 / 全部开 / 全部关」。项目级技能带「项目」标签,只有开 / 关两态。
28
29
  - **恢复跟随**:单项恢复点行尾的 ↺;整组恢复点表头的「跟随全局」。
29
30
 
@@ -40,6 +41,7 @@ DeepSeek Harness (DSH) 插件:用「全局持久化默认 + 会话级覆盖」
40
41
  - 子代理不继承父会话覆盖,需要在子代理会话内单独切换。
41
42
  - 状态文件只保证单进程单写者;同一 `DSH_HOME` 下并行运行多个 DSH 实例时,后写者会覆盖先写者。
42
43
  - 极少数安装失败场景(例如服务器正在重连、插件刚重载)可能出现「界面显示关闭,但工具或技能仍可见」;再切换一次或重启 DSH 即可恢复。
44
+ - 打包在 `app.asar` 内的技能(如 `dsh-doc`)没有可被文件管理器打开的本地目录;设置页只显示路径,不提供「所在目录」。
43
45
  - 会话技能列表只显示全局层与该会话实际装备的 preset 层;设置页的全局列表覆盖全部 preset。没有 preset 记录的旧会话会保守地读取全部 preset。
44
46
 
45
47
  ## 许可证
package/client.js CHANGED
@@ -17,6 +17,8 @@ window.__ModuleLoader__.load({
17
17
  const NS = 'mcp-skills-controller'
18
18
  const API = '/mcp-skills-controller/api'
19
19
  const TOKEN_META = 'dsh-mcp-skills-controller'
20
+ // 设置页 skills 展示分组顺序;项目级只属于会话,不进入全局面板。
21
+ const SKILL_GROUP_ORDER = ['user', 'plugin', 'preset', 'other']
20
22
 
21
23
  // settings.section 槽位按契约不声明 locale 字段,拿不到槽注入的 t;
22
24
  // apply 时绑定一份模块级兜底,GlobalPanel 内 `props.t ?? boundT`。
@@ -30,18 +32,22 @@ window.__ModuleLoader__.load({
30
32
  'scope.session': '仅本会话生效',
31
33
  'scope.default': '将用于之后新建的会话',
32
34
  'scope.project': '项目',
35
+ 'group.user': '用户',
36
+ 'group.plugin': '插件',
37
+ 'group.preset': '预设',
38
+ 'group.other': '其他',
33
39
  'action.followAll': '跟随全局',
34
40
  'action.followItem': '恢复跟随全局默认',
35
41
  'action.allOn': '全部开',
36
42
  'action.allOff': '全部关',
43
+ 'action.groupOn': '分组开',
44
+ 'action.groupOff': '分组关',
37
45
  'state.loading': '读取中…',
38
46
  'state.failed': '读取失败',
39
47
  'state.retry': '重试',
40
48
  'state.saving': '保存中…',
41
49
  'state.unsaved': '未写入磁盘',
42
50
  'state.corrupt': '状态文件损坏,已备份并恢复默认',
43
- 'mode.on': '开',
44
- 'mode.off': '关',
45
51
  'global.on': '全局默认:开',
46
52
  'global.off': '全局默认:关',
47
53
  'badge.all': '全开',
@@ -65,6 +71,7 @@ window.__ModuleLoader__.load({
65
71
  'reveal.unknownSkill': '技能已不存在',
66
72
  'reveal.noPath': '该技能没有文件位置',
67
73
  'reveal.missingDirectory': '目录已不存在',
74
+ 'reveal.packed': '该技能打包在应用内,没有可打开的本地目录',
68
75
  'reveal.failed': '打开目录失败',
69
76
  }
70
77
 
@@ -74,18 +81,22 @@ window.__ModuleLoader__.load({
74
81
  'scope.session': 'This conversation only',
75
82
  'scope.default': 'Applies to new conversations from here',
76
83
  'scope.project': 'Project',
84
+ 'group.user': 'Users',
85
+ 'group.plugin': 'Plugins',
86
+ 'group.preset': 'Preset',
87
+ 'group.other': 'Other',
77
88
  'action.followAll': 'Follow global',
78
89
  'action.followItem': 'Follow global default',
79
90
  'action.allOn': 'All on',
80
91
  'action.allOff': 'All off',
92
+ 'action.groupOn': 'Group on',
93
+ 'action.groupOff': 'Group off',
81
94
  'state.loading': 'Loading…',
82
95
  'state.failed': 'Load failed',
83
96
  'state.retry': 'Retry',
84
97
  'state.saving': 'Saving…',
85
98
  'state.unsaved': 'not written to disk',
86
99
  'state.corrupt': 'The state file was corrupt; backed up and reset to defaults',
87
- 'mode.on': 'On',
88
- 'mode.off': 'Off',
89
100
  'global.on': 'Global default: On',
90
101
  'global.off': 'Global default: Off',
91
102
  'badge.all': 'All on',
@@ -109,6 +120,7 @@ window.__ModuleLoader__.load({
109
120
  'reveal.unknownSkill': 'The skill no longer exists',
110
121
  'reveal.noPath': 'This skill has no file location',
111
122
  'reveal.missingDirectory': 'The folder no longer exists',
123
+ 'reveal.packed': 'This skill is packaged inside the app and has no local folder to open',
112
124
  'reveal.failed': 'Could not open the folder',
113
125
  }
114
126
 
@@ -428,28 +440,8 @@ window.__ModuleLoader__.load({
428
440
  左侧成一条线),不随描述长度浮动。 */
429
441
  .msc-itemSecondaryMain { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
430
442
  .msc-itemSecondaryGlob { flex: none; font-variant-numeric: tabular-nums; }
431
- /* 三态分段改为两段 [开][关](跟随走 ↺ 按钮):轨道用 interactive-bg-hover,
432
- 选中段用 bg-base + lv1 阴影 —— 与开关 thumb 同一语汇,明暗主题都成立。 */
433
- .msc-mode { flex: none; display: inline-flex; align-items: center; gap: 2px; align-self: center; }
434
- .msc-tri {
435
- flex: none; display: inline-flex; align-items: center; gap: 2px; padding: 2px;
436
- border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-interactive-bg-hover);
437
- }
438
- .msc-triSeg {
439
- padding: 1px 7px; border: none; border-radius: var(--dsw-radius-xs); outline: none;
440
- background: transparent;
441
- font-family: var(--dsw-font-family); font-size: 11px; line-height: 16px; font-weight: 500;
442
- color: var(--dsw-alias-label-tertiary); cursor: pointer;
443
- transition: color 120ms var(--ds-ease-in-out), background-color 120ms var(--ds-ease-in-out);
444
- }
445
- .msc-triSeg:hover:not(:disabled):not([data-active="true"]) { color: var(--dsw-alias-label-secondary); }
446
- .msc-triSeg[data-active="true"] {
447
- background: var(--dsw-alias-bg-base);
448
- color: var(--dsw-alias-label-primary);
449
- box-shadow: var(--dsw-shadow-lv1);
450
- }
451
- .msc-triSeg:focus-visible { outline: 2px solid var(--dsw-alias-border-l3); outline-offset: 1px; }
452
- .msc-triSeg:disabled { cursor: default; }
443
+ /* 会话行与设置页共用官方 Switch 外观:显式覆盖时右侧另起 ↺。 */
444
+ .msc-mode { flex: none; display: inline-flex; align-items: center; gap: 4px; align-self: center; }
453
445
  /* 单项恢复跟随:24px 图标按钮,仅覆盖存在时出现。 */
454
446
  .msc-follow {
455
447
  box-sizing: border-box; display: inline-flex;
@@ -516,11 +508,15 @@ window.__ModuleLoader__.load({
516
508
  border-radius: var(--dsw-radius-xl);
517
509
  padding: 2px 14px;
518
510
  }
519
- .msc-sectionHead { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
511
+ .msc-sectionHead { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 0 14px; }
520
512
  /* 动作按钮组:间距取 models 的 .rowActions(gap 4px)。 */
521
- .msc-sectionActions { display: inline-flex; align-items: center; gap: 4px; flex: none; }
522
513
  .msc-sectionTitle { margin: 0; font-size: 12px; line-height: 18px; font-weight: 500; color: var(--dsw-alias-label-secondary); }
523
514
  .msc-spacer { flex: 1; }
515
+ /* 设置页 skills 分组:组头(标签 + 三态开关)与组卡片分开;组与组之间留出呼吸。 */
516
+ .msc-group { display: flex; flex-direction: column; gap: 8px; }
517
+ .msc-group + .msc-group { margin-top: 20px; }
518
+ .msc-groupHead { display: flex; align-items: center; gap: 12px; padding: 0 14px; }
519
+ .msc-groupTitle { margin: 0; font-size: 12px; line-height: 18px; font-weight: 500; color: var(--dsw-alias-label-secondary); }
524
520
  /* 动作按钮:逐值照抄 ui-settings-models 的紧凑 secondary 按钮
525
521
  (提供方行的紧凑 secondary 按钮)——box-sizing、28px 高、0 10px、radius-sm、
526
522
  12px/18px、0.5px border-l3 描边、透明底、label-primary;hover 用
@@ -593,7 +589,9 @@ window.__ModuleLoader__.load({
593
589
  .msc-detailMeta { color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px; }
594
590
  .msc-detailEmpty { color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }
595
591
  .msc-toolList { display: flex; flex-wrap: wrap; gap: 6px; }
596
- .msc-pathRow { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
592
+ .msc-pathRow { display: flex; align-items: flex-start; gap: 10px; margin-top: 2px; }
593
+ /* 长路径会折行;动作按钮不参与收缩,避免「所在目录」被压成两行。 */
594
+ .msc-pathRow .msc-actionButton { flex: none; white-space: nowrap; }
597
595
  .msc-path {
598
596
  flex: 1 1 auto; min-width: 0;
599
597
  color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px;
@@ -623,6 +621,22 @@ window.__ModuleLoader__.load({
623
621
  }
624
622
  .msc-switch[aria-checked="false"]::after { background: var(--dsw-alias-switch-thumb); }
625
623
  .msc-switch[aria-checked="true"]::after { transform: translateX(16px); }
624
+ /* 部分开启:保持开关的滑块结构——轨道同「开」态,滑块居中,内部一道
625
+ 轨道色横杠(减号),表示「既非全开也非全关」。比起空心圈 + 实心点,
626
+ 它仍然读作一个开关,而不是两个圆点。 */
627
+ .msc-switch[aria-checked="mixed"] { background: var(--dsw-alias-brand-primary); }
628
+ .msc-switch[aria-checked="mixed"]::after {
629
+ transform: translateX(8px);
630
+ background: var(--dsw-alias-label-primary-foreground);
631
+ }
632
+ .msc-switch[aria-checked="mixed"]::before {
633
+ content: ""; position: absolute; z-index: 1;
634
+ left: 50%; top: 50%;
635
+ width: 6px; height: 2px;
636
+ transform: translate(-50%, -50%);
637
+ border-radius: 1px;
638
+ background: var(--dsw-alias-brand-primary);
639
+ }
626
640
  @media (prefers-reduced-motion: reduce) { .msc-switch::after { transition: none; } }
627
641
  .msc-emptyCard {
628
642
  padding: 12px;
@@ -644,24 +658,39 @@ window.__ModuleLoader__.load({
644
658
  return React.createElement(SpriteIcon, { name: 'refresh-outline', size })
645
659
  }
646
660
 
647
- /** 两段模式选择 [开][关]:高亮永远是当前实际生效值 —— 没有覆盖时高亮的就是
648
- * 全局状态;一旦存在显式覆盖,段旁出现 ↺ 单项恢复跟随全局。 */
649
- function ModeControl({ value, name, busy, followable, onFollow, onChange, t }) {
650
- const modes = [
651
- ['on', t('mode.on')],
652
- ['off', t('mode.off')],
653
- ]
654
- return React.createElement('div', { className: 'msc-mode', role: 'group', 'aria-label': name },
655
- React.createElement('div', { className: 'msc-tri' },
656
- modes.map(([mode, label]) => React.createElement('button', {
657
- key: mode,
661
+ /** 一组布尔值的聚合:全开 true、全关 false、混合 'mixed';空组按 false。 */
662
+ function bulkState(values) {
663
+ if (values.length === 0) return false
664
+ if (values.every((value) => value === true)) return true
665
+ if (values.every((value) => value !== true)) return false
666
+ return 'mixed'
667
+ }
668
+
669
+ /** 官方 Switch 外观的通用按钮:会话行、设置页行、区块头与组头共用。
670
+ * checked 为 true / false / 'mixed';mixed(部分开启)挂 aria-checked 的第三态。 */
671
+ function SwitchButton({ checked, label, disabled, onClick, title }) {
672
+ const ariaChecked = checked === 'mixed' ? 'mixed' : checked === true ? 'true' : 'false'
673
+ return React.createElement('button', {
658
674
  type: 'button',
659
- className: 'msc-triSeg',
660
- 'data-active': String(value === mode),
661
- 'aria-pressed': String(value === mode),
675
+ className: 'msc-switch',
676
+ role: 'switch',
677
+ 'aria-checked': ariaChecked,
678
+ 'aria-label': label,
679
+ title,
680
+ disabled: disabled === true,
681
+ onClick,
682
+ })
683
+ }
684
+
685
+ /** 会话行开关:显示当前实际生效值;有显式覆盖时右侧出现 ↺ 恢复跟随。 */
686
+ function ModeControl({ checked, name, busy, followable, onFollow, onChange, t }) {
687
+ return React.createElement('div', { className: 'msc-mode' },
688
+ React.createElement(SwitchButton, {
689
+ checked,
690
+ label: name,
662
691
  disabled: busy === true,
663
- onClick: () => { onChange(mode) },
664
- }, label))),
692
+ onClick: () => { onChange(checked === true ? 'off' : 'on') },
693
+ }),
665
694
  followable && React.createElement('button', {
666
695
  type: 'button',
667
696
  className: 'msc-follow',
@@ -699,6 +728,7 @@ window.__ModuleLoader__.load({
699
728
  /** reveal 失败原因 → 本地化文案;未知原因回退通用提示。 */
700
729
  function revealFailureText(reason, t) {
701
730
  if (reason === 'no-path') return t('reveal.noPath')
731
+ if (reason === 'packed') return t('reveal.packed')
702
732
  if (reason === 'missing-directory') return t('reveal.missingDirectory')
703
733
  if (reason === 'unknown-skill') return t('reveal.unknownSkill')
704
734
  return t('reveal.failed')
@@ -928,7 +958,7 @@ window.__ModuleLoader__.load({
928
958
  React.createElement(ModeControl, {
929
959
  // 控件显示「当前实际生效值」:无覆盖时即全局状态;有覆盖时是显式值,
930
960
  // 此时出现 ↺ 单项恢复跟随。
931
- value: item.effective === false ? 'off' : 'on',
961
+ checked: item.effective === true,
932
962
  name: item.name,
933
963
  busy,
934
964
  followable: item.mode !== 'follow',
@@ -957,7 +987,7 @@ window.__ModuleLoader__.load({
957
987
  !project && React.createElement('span', { className: 'msc-itemSecondaryGlob' },
958
988
  item.global === true ? t('global.on') : t('global.off')))),
959
989
  React.createElement(ModeControl, {
960
- value: item.effective === false ? 'off' : 'on',
990
+ checked: item.effective === true,
961
991
  name: item.name,
962
992
  busy,
963
993
  // 项目级技能没有「跟随全局」可恢复:不显示 ↺,点「开」即回到默认开。
@@ -1035,18 +1065,40 @@ window.__ModuleLoader__.load({
1035
1065
  const stateWarning = data?.stateWarning
1036
1066
  const skillsIncomplete = data?.skills?.complete === false
1037
1067
 
1038
- /** 写全局默认;item 省略表示整组。 */
1039
- const setGlobal = (kind, item, enabled) => {
1068
+ /** 旧宿主兼容:缺 group 时按 origin 兜底;两者都没有则归其他。 */
1069
+ const groupOfSkill = (skill) => {
1070
+ if (typeof skill.group === 'string') return skill.group
1071
+ if (skill.origin === 'user') return 'user'
1072
+ if (skill.origin === 'package' || skill.origin === 'custom') return 'preset'
1073
+ if (skill.origin === 'plugin') return 'plugin'
1074
+ return 'other'
1075
+ }
1076
+
1077
+ /** 按固定顺序分组;空组不渲染,避免出现没有行的标题。 */
1078
+ const skillGroups = SKILL_GROUP_ORDER
1079
+ .map((group) => ({ group, rows: skills.filter((skill) => groupOfSkill(skill) === group) }))
1080
+ .filter((entry) => entry.rows.length > 0)
1081
+
1082
+ /** 写全局默认;item 省略表示整组。group 只在 item 省略时生效:
1083
+ * 指定后由宿主按分类挑选该组技能,客户端不传名字列表。 */
1084
+ const setGlobal = (kind, item, enabled, group) => {
1040
1085
  if (busyKey !== undefined) return
1086
+ const all = item === undefined
1087
+ const busy = all
1088
+ ? (group === undefined ? `all:${kind}` : `group:${kind}:${group}`)
1089
+ : `${kind}:${item}`
1090
+ const payload = all
1091
+ ? { kind, enabled, ...(group === undefined ? {} : { group }) }
1092
+ : { kind, item, enabled }
1041
1093
  void runMutation({
1042
1094
  requestRef,
1043
1095
  setBusyKey,
1044
1096
  setError,
1045
1097
  setNotice,
1046
- busy: item === undefined ? `all:${kind}` : `${kind}:${item}`,
1047
- run: () => api(item === undefined ? '/global/all' : '/global/set', {
1098
+ busy,
1099
+ run: () => api(all ? '/global/all' : '/global/set', {
1048
1100
  method: 'POST',
1049
- payload: item === undefined ? { kind, enabled } : { kind, item, enabled },
1101
+ payload,
1050
1102
  }),
1051
1103
  onSuccess: (payload) => {
1052
1104
  setState({ phase: 'ready', data: payload })
@@ -1097,23 +1149,22 @@ window.__ModuleLoader__.load({
1097
1149
  }
1098
1150
  }
1099
1151
 
1100
- /** 区块头:组标题(原生 modelCatalogTitle 基准)+ 右侧 secondary 动作按钮。 */
1101
- const renderSectionHead = (titleKey, kind) => React.createElement('div', { className: 'msc-sectionHead' },
1102
- React.createElement('h3', { className: 'msc-sectionTitle' }, t(titleKey)),
1103
- React.createElement('span', { className: 'msc-spacer' }),
1104
- React.createElement('span', { className: 'msc-sectionActions' },
1105
- React.createElement('button', {
1106
- type: 'button',
1107
- className: 'msc-actionButton',
1108
- disabled: busyKey !== undefined,
1109
- onClick: () => { void setGlobal(kind, undefined, true) },
1110
- }, t('action.allOn')),
1111
- React.createElement('button', {
1112
- type: 'button',
1113
- className: 'msc-actionButton',
1114
- disabled: busyKey !== undefined,
1115
- onClick: () => { void setGlobal(kind, undefined, false) },
1116
- }, t('action.allOff'))))
1152
+ /** 区块头:标题 + 与条目开关右缘对齐的三态开关(无条目时不显示)。 */
1153
+ const renderSectionHead = (titleKey, kind) => {
1154
+ const rows = kind === 'mcp' ? mcpServers : skills
1155
+ const state = bulkState(rows.map((row) => row.enabled === true))
1156
+ const action = state === true ? t('action.allOff') : t('action.allOn')
1157
+ return React.createElement('div', { className: 'msc-sectionHead' },
1158
+ React.createElement('h3', { className: 'msc-sectionTitle' }, t(titleKey)),
1159
+ React.createElement('span', { className: 'msc-spacer' }),
1160
+ rows.length > 0 && React.createElement(SwitchButton, {
1161
+ checked: state,
1162
+ label: t(titleKey),
1163
+ title: `${t(titleKey)} — ${action}`,
1164
+ disabled: busyKey !== undefined,
1165
+ onClick: () => { void setGlobal(kind, undefined, state !== true) },
1166
+ }))
1167
+ }
1117
1168
 
1118
1169
  /** 全局 MCP 行:主行(题 + 说明 + 展开/开关)+ 展开后的工具列表。 */
1119
1170
  const renderMcpRow = (server) => {
@@ -1149,12 +1200,9 @@ window.__ModuleLoader__.load({
1149
1200
  React.createElement('div', { className: 'msc-rowDesc' }, meta)),
1150
1201
  React.createElement('div', { className: 'msc-rowActions' },
1151
1202
  React.createElement(ExpandIndicator, { open, t }),
1152
- React.createElement('button', {
1153
- type: 'button',
1154
- className: 'msc-switch',
1155
- role: 'switch',
1156
- 'aria-checked': String(server.enabled === true),
1157
- 'aria-label': server.name,
1203
+ React.createElement(SwitchButton, {
1204
+ checked: server.enabled === true,
1205
+ label: server.name,
1158
1206
  disabled: busyKey !== undefined,
1159
1207
  onClick: (event) => {
1160
1208
  // 开关是行内独立动作:阻止冒泡,避免点开关时同时展开/收起详情。
@@ -1178,6 +1226,7 @@ window.__ModuleLoader__.load({
1178
1226
  const renderSkillRow = (skill) => {
1179
1227
  const open = isExpanded('skills', skill.name)
1180
1228
  const path = typeof skill.path === 'string' && skill.path.length > 0 ? skill.path : undefined
1229
+ const packed = skill.packed === true
1181
1230
  const meta = [skill.source, skill.provider]
1182
1231
  .filter((part) => part !== undefined && part !== null && part !== '')
1183
1232
  .join(' · ')
@@ -1203,12 +1252,9 @@ window.__ModuleLoader__.load({
1203
1252
  React.createElement('div', { className: 'msc-rowDesc' }, skill.description ?? '')),
1204
1253
  React.createElement('div', { className: 'msc-rowActions' },
1205
1254
  React.createElement(ExpandIndicator, { open, t }),
1206
- React.createElement('button', {
1207
- type: 'button',
1208
- className: 'msc-switch',
1209
- role: 'switch',
1210
- 'aria-checked': String(skill.enabled === true),
1211
- 'aria-label': skill.name,
1255
+ React.createElement(SwitchButton, {
1256
+ checked: skill.enabled === true,
1257
+ label: skill.name,
1212
1258
  disabled: busyKey !== undefined,
1213
1259
  onClick: (event) => {
1214
1260
  // 开关是行内独立动作:阻止冒泡,避免点开关时同时展开/收起详情。
@@ -1219,10 +1265,11 @@ window.__ModuleLoader__.load({
1219
1265
  open && React.createElement('div', { className: 'msc-rowDetail' },
1220
1266
  React.createElement('div', { className: 'msc-detailDesc' }, skill.description ?? ''),
1221
1267
  meta !== '' && React.createElement('div', { className: 'msc-detailMeta' }, meta),
1222
- // 虚拟技能没有指令文件,展开区不显示位置行与按钮。
1268
+ // 虚拟技能没有指令文件,展开区不显示位置行;asar 内的路径不可被文件管理器打开,
1269
+ // 只显示路径,不给出必然失败的动作按钮。
1223
1270
  path !== undefined && React.createElement('div', { className: 'msc-pathRow' },
1224
1271
  React.createElement('span', { className: 'msc-path' }, path),
1225
- React.createElement('button', {
1272
+ !packed && React.createElement('button', {
1226
1273
  type: 'button',
1227
1274
  className: 'msc-actionButton',
1228
1275
  disabled: revealing === skill.name,
@@ -1230,6 +1277,25 @@ window.__ModuleLoader__.load({
1230
1277
  }, t('action.reveal')))))
1231
1278
  }
1232
1279
 
1280
+ /** 单个来源分组:组头标签 + 三态开关(开 / 关 / 部分开启)。 */
1281
+ const renderSkillGroup = ({ group, rows }) => {
1282
+ const label = t(`group.${group}`)
1283
+ const state = bulkState(rows.map((row) => row.enabled === true))
1284
+ const action = state === true ? t('action.groupOff') : t('action.groupOn')
1285
+ return React.createElement('div', { key: group, className: 'msc-group' },
1286
+ React.createElement('div', { className: 'msc-groupHead' },
1287
+ React.createElement('h4', { className: 'msc-groupTitle' }, label),
1288
+ React.createElement('span', { className: 'msc-spacer' }),
1289
+ React.createElement(SwitchButton, {
1290
+ checked: state,
1291
+ label,
1292
+ title: `${label} — ${action}`,
1293
+ disabled: busyKey !== undefined,
1294
+ onClick: () => { void setGlobal('skills', undefined, state !== true, group) },
1295
+ })),
1296
+ React.createElement('div', { className: 'msc-card' }, rows.map(renderSkillRow)))
1297
+ }
1298
+
1233
1299
  return React.createElement('div', { className: 'msc-page' },
1234
1300
  React.createElement('div', { className: 'msc-pageHead' },
1235
1301
  React.createElement('div', { className: 'msc-pageHeaderText' },
@@ -1266,10 +1332,10 @@ window.__ModuleLoader__.load({
1266
1332
  : mcpServers.map(renderMcpRow))),
1267
1333
  React.createElement('section', { className: 'msc-section' },
1268
1334
  renderSectionHead('section.skills', 'skills'),
1269
- React.createElement('div', { className: 'msc-card' },
1270
1335
  skills.length === 0
1271
- ? React.createElement('div', { className: 'msc-emptyCard' }, t('skills.empty'))
1272
- : skills.map(renderSkillRow)),
1336
+ ? React.createElement('div', { className: 'msc-card' },
1337
+ React.createElement('div', { className: 'msc-emptyCard' }, t('skills.empty')))
1338
+ : skillGroups.map(renderSkillGroup),
1273
1339
  skillsIncomplete && React.createElement('p', {
1274
1340
  className: 'msc-statusText',
1275
1341
  'data-tone': 'warn',
package/icon.svg CHANGED
@@ -1,6 +1,8 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
2
- <!-- 滑杆组:上轨表示 MCP 服务器注入,下轨表示 skills 注入,圆点即开关位置 -->
3
- <path d="M3 7h18M3 17h18" />
4
- <circle cx="9" cy="7" r="2.6" />
5
- <circle cx="15" cy="17" r="2.6" />
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36" width="36" height="36" fill="none">
2
+ <!-- 滑杆组:上轨表示 MCP 服务器注入,下轨表示 skills 注入,圆点即开关位置。
3
+ DSH 以 <img> 加载插件图标,不继承页面 currentColor;用固定蓝色系保证
4
+ 在深色与浅色面板上都可辨认,不依赖主题反色。 -->
5
+ <path d="M5 12h26M5 24h26" stroke="#4C8DF6" stroke-width="2.2" stroke-linecap="round" />
6
+ <circle cx="14" cy="12" r="4.2" fill="#4C8DF6" stroke="#2F6BD8" stroke-width="1.4" />
7
+ <circle cx="23" cy="24" r="4.2" fill="#F4F8FF" stroke="#2F6BD8" stroke-width="1.4" />
6
8
  </svg>
package/index.js CHANGED
@@ -29,7 +29,8 @@ import {
29
29
  } from './src/merge.js'
30
30
  import { loadStateReport, saveState } from './src/state.js'
31
31
  import { createCatalogs } from './src/catalogs.js'
32
- import { isProjectSource } from './src/skill-catalog.js'
32
+ import { isProjectSource, skillGroupOf, skillOrigin } from './src/skill-origin.js'
33
+ import { isPackedPath } from './src/skill-path.js'
33
34
  import { createMcpMaskEngine } from './src/masks.js'
34
35
  import { createSkillShadowEngine } from './src/shadows.js'
35
36
  import * as views from './src/views.js'
@@ -247,13 +248,23 @@ export function apply(ctx, rawConfig = {}) {
247
248
  () => setGlobalEnabled(state, kind, item, enabled),
248
249
  ),
249
250
 
250
- /** 全局整组开关;重算语义同 globalSet。项目级技能不在全局目录里。 */
251
- globalAll: async ({ kind, enabled }) => {
252
- const items = kind === 'mcp'
253
- ? catalogs.mcp().map((server) => server.name)
254
- : (await catalogs.skillsGlobal()).skills
251
+ /**
252
+ * 全局整组开关;重算语义同 globalSet。项目级技能不在全局目录里。
253
+ * group 省略 = 全部 skills;指定时只作用于该展示分组(user / plugin /
254
+ * preset / other),由宿主按 source 分类挑选,客户端不传名字列表。
255
+ */
256
+ globalAll: async ({ kind, enabled, group }) => {
257
+ let items
258
+ if (kind === 'mcp') {
259
+ items = catalogs.mcp().map((server) => server.name)
260
+ } else {
261
+ const catalog = await catalogs.skillsGlobal()
262
+ items = catalog.skills
255
263
  .filter((row) => !isProjectSource(row.source))
264
+ .filter((row) => group === undefined
265
+ || skillGroupOf(skillOrigin(row.source).origin) === group)
256
266
  .map((row) => row.name)
267
+ }
257
268
  return commitGlobal(() => setGlobalAll(state, kind, enabled, items))
258
269
  },
259
270
 
@@ -269,6 +280,8 @@ export function apply(ctx, rawConfig = {}) {
269
280
  if (typeof row.path !== 'string' || row.path.length === 0) {
270
281
  return { revealed: false, reason: 'no-path' }
271
282
  }
283
+ // 打包在 app.asar 内的技能:ctx.fs 能读,但文件管理器进不去归档。
284
+ if (isPackedPath(row.path)) return { revealed: false, reason: 'packed' }
272
285
  const directory = dirname(row.path)
273
286
  if (!existsSync(directory)) return { revealed: false, reason: 'missing-directory' }
274
287
  await openDirectory(directory)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mcp-skills-controller",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "以「全局持久化默认 + 会话级三态覆盖」统一管理 MCP 服务器与 skills 的注入可见性;零侵入,不改任何配置文件。",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -50,8 +50,8 @@
50
50
  "skills"
51
51
  ],
52
52
  "scripts": {
53
- "check": "node --check index.js && node --check client.js && node --check src/merge.js && node --check src/state.js && node --check src/mcp-catalog.js && node --check src/skill-catalog.js && node --check src/session.js && node --check src/frozen-registry.js && node --check src/catalogs.js && node --check src/views.js && node --check src/agent-hooks.js && node --check src/masks.js && node --check src/shadows.js && node --check src/reveal.js && node --check src/rpc.js",
54
- "test": "node tests/merge-test.mjs && node tests/state-test.mjs && node tests/mcp-catalog-test.mjs && node tests/skill-catalog-test.mjs && node tests/masks-test.mjs && node tests/shadows-test.mjs && node tests/frozen-registry-test.mjs && node tests/views-test.mjs && node tests/agent-hooks-test.mjs && node tests/reveal-test.mjs && node tests/rpc-test.mjs && node tests/contract-test.mjs",
53
+ "check": "node --check index.js && node --check client.js && node --check src/merge.js && node --check src/state.js && node --check src/mcp-catalog.js && node --check src/skill-catalog.js && node --check src/skill-origin.js && node --check src/skill-path.js && node --check src/session.js && node --check src/frozen-registry.js && node --check src/catalogs.js && node --check src/views.js && node --check src/agent-hooks.js && node --check src/masks.js && node --check src/shadows.js && node --check src/reveal.js && node --check src/rpc.js",
54
+ "test": "node tests/merge-test.mjs && node tests/state-test.mjs && node tests/mcp-catalog-test.mjs && node tests/skill-catalog-test.mjs && node tests/skill-origin-test.mjs && node tests/masks-test.mjs && node tests/shadows-test.mjs && node tests/frozen-registry-test.mjs && node tests/views-test.mjs && node tests/agent-hooks-test.mjs && node tests/reveal-test.mjs && node tests/rpc-test.mjs && node tests/contract-test.mjs",
55
55
  "prepack": "npm run check",
56
56
  "prepublishOnly": "npm run check"
57
57
  }
package/src/rpc.js CHANGED
@@ -30,6 +30,9 @@ const KINDS = ['mcp', 'skills']
30
30
  /** 会话覆盖三态的合法值。 */
31
31
  const MODES = ['on', 'off', 'follow']
32
32
 
33
+ /** 全局 skills 分组的合法值(项目级不进入全局面板)。 */
34
+ const GROUPS = ['user', 'plugin', 'preset', 'other']
35
+
33
36
  /**
34
37
  * 创建并注册 RPC 路由。
35
38
  * @param ctx 插件上下文(须注入 webServer)。
@@ -120,6 +123,13 @@ export function registerRpc(ctx, { token, log, handlers }) {
120
123
  return value
121
124
  }
122
125
 
126
+ const requireGroup = (value) => {
127
+ if (!GROUPS.includes(value)) {
128
+ throw new InvalidArgument('invalid-group', "group 必须是 'user'、'plugin'、'preset' 或 'other'")
129
+ }
130
+ return value
131
+ }
132
+
123
133
  return ctx.webServer.register({
124
134
  kind: 'prefix',
125
135
  path: API_PREFIX,
@@ -190,6 +200,13 @@ export function registerRpc(ctx, { token, log, handlers }) {
190
200
  kind: requireKind(body.kind),
191
201
  enabled: requireEnabled(body.enabled),
192
202
  }
203
+ // group 只用于 skills;MCP 没有分组概念,带上就直接拒绝,避免静默忽略。
204
+ if (body.group !== undefined) {
205
+ if (args.kind !== 'skills') {
206
+ throw new InvalidArgument('invalid-group', 'group 仅适用于 skills')
207
+ }
208
+ args.group = requireGroup(body.group)
209
+ }
193
210
  const { persisted, payload } = await handlers.globalAll(args)
194
211
  return sendJson(res, 200, { ok: true, persisted, ...payload })
195
212
  }
package/src/shadows.js CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  import { createFrozenRegistry } from './frozen-registry.js'
24
24
  import { catalogKey, cwdOf, presetOf } from './session.js'
25
- import { isProjectSource } from './skill-catalog.js'
25
+ import { isProjectSource } from './skill-origin.js'
26
26
 
27
27
  /**
28
28
  * 进程级遮蔽登记表的键(热重载代际接手,语义同 masks.js 的 MASKS_KEY)。
@@ -22,16 +22,6 @@
22
22
  * @property {string | undefined} [path] 指令文件绝对路径(虚拟技能没有)。
23
23
  */
24
24
 
25
- /**
26
- * 是否项目级技能:DSH skill-filesystem 的项目根来源是 `project-dsh`
27
- * (`<projectRoot>/.dsh/skills`)与 `project-agents`(`<projectRoot>/.agents/skills`)。
28
- * 项目级技能只在会话级出现,没有全局默认,忽略 state.skills.global。
29
- * @param source 技能的 source 标签。
30
- */
31
- export function isProjectSource(source) {
32
- return typeof source === 'string' && source.startsWith('project-')
33
- }
34
-
35
25
  /**
36
26
  * 冷读一次技能目录。
37
27
  * @param ctx 插件上下文(经 `ctx.get` 机会式获取 `skills` 与 `agentPresets`)。
@@ -0,0 +1,82 @@
1
+ /**
2
+ * skills 来源分类:把 DSH 的 `source` 投影成两个正交维度。
3
+ *
4
+ * - `scope`:控制语义。`project` 只属于当前会话(无全局默认、不显示 ↺);
5
+ * `global` 走「全局默认 + 会话覆盖」。
6
+ * - `origin`:展示归属。`user` 用户根、`project` 项目根、`package` 随包、
7
+ * `custom` 配置挂载、`plugin` 运行时注册、`unknown` 未知。
8
+ *
9
+ * 注意:`preset` 不是 `source` 能表达的属性——它描述「谁挂载」,而 preset 层
10
+ * 同时包含 custom 与用户根技能;host 层的 bundled 技能也不属于任何 preset。
11
+ * 因此这里只按来源分类,`preset` 只作为设置页展示分组(package + custom)。
12
+ *
13
+ * @module skill-origin
14
+ */
15
+
16
+ /** 设置页展示分组顺序:用户 → 插件 → 预设 → 其他(项目级不进入全局面板)。 */
17
+ export const SKILL_GROUPS = Object.freeze(['user', 'plugin', 'preset', 'other'])
18
+
19
+ /** `source` → `origin`。未知值按 family 前缀兜底,不猜测归属。 */
20
+ const ORIGIN_BY_SOURCE = Object.freeze({
21
+ 'user-dsh': 'user',
22
+ 'user-agents': 'user',
23
+ 'project-dsh': 'project',
24
+ 'project-agents': 'project',
25
+ bundled: 'package',
26
+ custom: 'custom',
27
+ runtime: 'plugin',
28
+ })
29
+
30
+ /** `origin` → 展示分组。package 与 custom 都归入「预设」,plugin 单列。 */
31
+ const GROUP_BY_ORIGIN = Object.freeze({
32
+ user: 'user',
33
+ project: 'project',
34
+ package: 'preset',
35
+ custom: 'preset',
36
+ plugin: 'plugin',
37
+ unknown: 'other',
38
+ })
39
+
40
+ /**
41
+ * 只读取映射表自有键;`source` 可能来自第三方 provider,避免命中原型链
42
+ * (如 `constructor` / `__proto__`)后把函数当成 origin。
43
+ * @param map 冻结的映射表。
44
+ * @param key 外部传入的键。
45
+ * @returns 命中的值,或 undefined。
46
+ */
47
+ function ownValue(map, key) {
48
+ return typeof key === 'string' && Object.hasOwn(map, key) ? map[key] : undefined
49
+ }
50
+
51
+ /**
52
+ * 把 DSH 的 `source` 投影成 `{ scope, origin }`。
53
+ * @param source 技能来源标签;可能缺失,也可能是任意第三方字符串。
54
+ */
55
+ export function skillOrigin(source) {
56
+ if (typeof source === 'string') {
57
+ const known = ownValue(ORIGIN_BY_SOURCE, source)
58
+ if (known !== undefined) {
59
+ return { scope: known === 'project' ? 'project' : 'global', origin: known }
60
+ }
61
+ // DSH 允许第三方扩展 source;按 family 前缀兜底比精确表更耐新增值。
62
+ if (source.startsWith('project-')) return { scope: 'project', origin: 'project' }
63
+ if (source.startsWith('user-')) return { scope: 'global', origin: 'user' }
64
+ }
65
+ return { scope: 'global', origin: 'unknown' }
66
+ }
67
+
68
+ /**
69
+ * `origin` → 设置页分组;未知 origin 一律归入 other。
70
+ * @param origin {@link skillOrigin} 产出的归属。
71
+ */
72
+ export function skillGroupOf(origin) {
73
+ return ownValue(GROUP_BY_ORIGIN, origin) ?? 'other'
74
+ }
75
+
76
+ /**
77
+ * 是否项目级技能。只认 `scope`,不在各调用点重复字符串前缀规则。
78
+ * @param source 技能的 source 标签。
79
+ */
80
+ export function isProjectSource(source) {
81
+ return skillOrigin(source).scope === 'project'
82
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 技能指令文件路径的可用性判断。
3
+ *
4
+ * DSH 的桌面安装把部分随包技能放在 `resources/app.asar` 里:`ctx.fs` 能读,
5
+ * 但操作系统文件管理器把 `app.asar` 当作单个文件,无法进入其内部目录。
6
+ * 这里给宿主与快照提供同一套判断,避免 UI 给出一个必然失败的「所在目录」。
7
+ *
8
+ * @module skill-path
9
+ */
10
+
11
+ /** 打包在 Electron asar 归档内的路径(按路径分隔符判断,兼容 Windows 与 POSIX)。 */
12
+ const PACKED_APP_ASAR = /(^|[\\/])app\.asar[\\/]/i
13
+
14
+ /**
15
+ * 是否位于 `app.asar` 归档内。
16
+ * @param path 技能指令文件路径;可能缺失或为任意值。
17
+ * @returns 归档内返回 true;普通磁盘路径、`app.asar.unpacked` 等返回 false。
18
+ */
19
+ export function isPackedPath(path) {
20
+ return typeof path === 'string' && PACKED_APP_ASAR.test(path)
21
+ }
package/src/views.js CHANGED
@@ -1,88 +1,109 @@
1
- /**
2
- * 快照行映射:会话面与设置页共用同一套字段口径。
3
- *
4
- * 这里只做「目录行 + 决策表 + state」到可发送 payload 的纯映射,不读目录、
5
- * 不装掩码。index.js 只负责取目录、算决策和组装外层信封。
6
- *
7
- * @module views
8
- */
9
-
10
- import { sessionMode } from './merge.js'
11
- import { isProjectSource } from './skill-catalog.js'
12
-
13
- /** 会话 MCP 快照:目录 + 生效值 + 三态模式。 */
14
- export function sessionMcpView({ sessionId, catalog, decisions, state }) {
15
- return {
16
- session: sessionId,
17
- mcp: {
18
- servers: catalog.map((server) => ({
19
- name: server.name,
20
- transport: server.transport,
21
- target: server.target,
22
- tools: server.tools.length,
23
- connected: server.connected,
24
- global: state.mcp.global[server.name] !== false,
25
- mode: sessionMode(state, 'mcp', sessionId, server.name),
26
- effective: decisions.get(server.name) === true,
27
- })),
28
- },
29
- }
30
- }
31
-
32
- /** 会话 skills 快照:项目级标记、生效值与目录完整度。 */
33
- export function sessionSkillsView({ sessionId, catalog, decisions, state }) {
34
- const { skills, complete } = catalog
35
- const rows = skills.map((row) => ({
36
- name: row.name,
37
- description: row.description,
38
- source: row.source,
39
- provider: row.provider,
40
- invocation: row.invocation,
41
- project: isProjectSource(row.source),
42
- global: state.skills.global[row.name] !== false,
43
- mode: sessionMode(state, 'skills', sessionId, row.name),
44
- effective: decisions.get(row.name) === true,
45
- }))
46
- return {
47
- session: sessionId,
48
- skills: { skills: rows, complete },
49
- }
50
- }
51
-
52
- /** 设置页 MCP 快照:展开区需要的裸工具名。 */
53
- export function globalMcpView({ catalog, state }) {
54
- return {
55
- mcp: {
56
- servers: catalog.map((server) => ({
57
- name: server.name,
58
- transport: server.transport,
59
- target: server.target,
60
- tools: server.tools.length,
61
- toolNames: server.toolNames,
62
- connected: server.connected,
63
- enabled: state.mcp.global[server.name] !== false,
64
- })),
65
- },
66
- }
67
- }
68
-
69
- /** 设置页 skills 快照:项目级技能只属于会话,全局视图过滤。 */
70
- export function globalSkillsView({ catalog, state }) {
71
- const { skills, complete } = catalog
72
- return {
73
- skills: {
74
- skills: skills
75
- .filter((row) => !isProjectSource(row.source))
76
- .map((row) => ({
77
- name: row.name,
78
- description: row.description,
79
- source: row.source,
80
- provider: row.provider,
81
- invocation: row.invocation,
82
- path: row.path,
83
- enabled: state.skills.global[row.name] !== false,
84
- })),
85
- complete,
86
- },
87
- }
88
- }
1
+ /**
2
+ * 快照行映射:会话面与设置页共用同一套字段口径。
3
+ *
4
+ * 这里只做「目录行 + 决策表 + state」到可发送 payload 的纯映射,不读目录、
5
+ * 不装掩码。index.js 只负责取目录、算决策和组装外层信封。
6
+ *
7
+ * 分类字段(scope / origin / group)来自 skill-origin;其中只有 scope 影响
8
+ * 控制语义,origin 与 group 仅用于展示。
9
+ *
10
+ * @module views
11
+ */
12
+
13
+ import { sessionMode } from './merge.js'
14
+ import { skillGroupOf, skillOrigin } from './skill-origin.js'
15
+ import { isPackedPath } from './skill-path.js'
16
+
17
+ /**
18
+ * 目录行 → 快照分类字段。返回值即 payload 的三枚键,避免两处各算一遍。
19
+ * @param source 技能的 source 标签。
20
+ */
21
+ function skillFacts(source) {
22
+ const { scope, origin } = skillOrigin(source)
23
+ return { scope, origin, group: skillGroupOf(origin) }
24
+ }
25
+
26
+ /** 会话 MCP 快照:目录 + 生效值 + 三态模式。 */
27
+ export function sessionMcpView({ sessionId, catalog, decisions, state }) {
28
+ return {
29
+ session: sessionId,
30
+ mcp: {
31
+ servers: catalog.map((server) => ({
32
+ name: server.name,
33
+ transport: server.transport,
34
+ target: server.target,
35
+ tools: server.tools.length,
36
+ connected: server.connected,
37
+ global: state.mcp.global[server.name] !== false,
38
+ mode: sessionMode(state, 'mcp', sessionId, server.name),
39
+ effective: decisions.get(server.name) === true,
40
+ })),
41
+ },
42
+ }
43
+ }
44
+
45
+ /** 会话 skills 快照:项目标记、分类字段、生效值与目录完整度。 */
46
+ export function sessionSkillsView({ sessionId, catalog, decisions, state }) {
47
+ const { skills, complete } = catalog
48
+ const rows = skills.map((row) => {
49
+ const facts = skillFacts(row.source)
50
+ return {
51
+ name: row.name,
52
+ description: row.description,
53
+ source: row.source,
54
+ provider: row.provider,
55
+ invocation: row.invocation,
56
+ ...facts,
57
+ // 兼容字段:现有 merge/shadows 与客户端按 project 布尔判定项目级。
58
+ project: facts.scope === 'project',
59
+ global: state.skills.global[row.name] !== false,
60
+ mode: sessionMode(state, 'skills', sessionId, row.name),
61
+ effective: decisions.get(row.name) === true,
62
+ }
63
+ })
64
+ return {
65
+ session: sessionId,
66
+ skills: { skills: rows, complete },
67
+ }
68
+ }
69
+
70
+ /** 设置页 MCP 快照:展开区需要的裸工具名。 */
71
+ export function globalMcpView({ catalog, state }) {
72
+ return {
73
+ mcp: {
74
+ servers: catalog.map((server) => ({
75
+ name: server.name,
76
+ transport: server.transport,
77
+ target: server.target,
78
+ tools: server.tools.length,
79
+ toolNames: server.toolNames,
80
+ connected: server.connected,
81
+ enabled: state.mcp.global[server.name] !== false,
82
+ })),
83
+ },
84
+ }
85
+ }
86
+
87
+ /** 设置页 skills 快照:项目级技能只属于会话,全局视图过滤。 */
88
+ export function globalSkillsView({ catalog, state }) {
89
+ const { skills, complete } = catalog
90
+ return {
91
+ skills: {
92
+ skills: skills
93
+ .filter((row) => skillOrigin(row.source).scope !== 'project')
94
+ .map((row) => ({
95
+ name: row.name,
96
+ description: row.description,
97
+ source: row.source,
98
+ provider: row.provider,
99
+ invocation: row.invocation,
100
+ path: row.path,
101
+ // asar 内的路径在系统文件管理器里不可进入;客户端据此隐藏「所在目录」。
102
+ packed: isPackedPath(row.path),
103
+ ...skillFacts(row.source),
104
+ enabled: state.skills.global[row.name] !== false,
105
+ })),
106
+ complete,
107
+ },
108
+ }
109
+ }