dsh-plugins-scope 0.5.1 → 0.6.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/CHANGELOG.md +15 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/client.js +178 -8
- package/docs/DETAIL.en.md +1 -1
- package/docs/DETAIL.md +1 -1
- package/index.js +269 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
- 新增通用客户端 UI 作用域过滤:包装 `ctx.slots.register/registerFactory` 与 `contextMenus`,按注册包隐藏整个插件 UI;不再为单个插件写 CSS。
|
|
6
|
+
- 服务端扫描每个包的 `client.js` slot id,写入 `clientIds`;修复无 `key` 的 UI(如 `persona-dock`、`windows-mcp-computer-use`)。
|
|
7
|
+
- 新增命令(commands)作用域:静态扫描 + 运行期 owner,关闭后 `/purge` 等命令从列表、查找、执行三处消失。
|
|
8
|
+
- 修复 `hiddenForSession()` 使用未定义 `sid` 导致所有 turn 报 `sid is not defined`。
|
|
9
|
+
- `dsh-harness-remote`、`@linxin666/dsh-remote-web-ui` 判定为仅全局,不参与会话/工作区开关;它们的 13 个远程工具是 Agent 控制面,不是会话插件。
|
|
10
|
+
- 修复 profile 解析对旧依赖名 `dsh-scope-manager` 的回退。
|
|
11
|
+
|
|
12
|
+
## 0.5.2
|
|
13
|
+
|
|
14
|
+
- 分叉会话与子代理沿父链继承父会话的覆盖值(不复制);父会话归档仍可解析,删除后回落到工作区。
|
|
15
|
+
- 会话窗口的“跟随”标签区分“跟随父会话”与“跟随工作区”;父会话有覆盖时显示父值。
|
|
16
|
+
- 读取持久化的会话头(`sessions/*/session.v4.jsonl.zstd`)作为非活跃会话的父链来源,并做进程内缓存。
|
|
17
|
+
|
|
3
18
|
## 0.5.1
|
|
4
19
|
|
|
5
20
|
- 工作区/会话右键菜单的「插件作用域…」增加与重命名、删除同级的 SVG 图标。
|
package/README.en.md
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
| `llm/stream` hooks | That session skips the plugin's listeners on the next request |
|
|
30
30
|
| Pure UI / global services | Global toggle only; flips the profile bundle and asks for a restart |
|
|
31
31
|
|
|
32
|
-
Limitations:
|
|
32
|
+
Limitations: pure client UI is loaded once per web boot; a plugin's own timers/background services are not stopped by “off”. Forked sessions and subagents read the parent session's overrides first (walking the parent chain, not copying them); if the parent is deleted they fall back to the workspace. This plugin is a scope manager, not a sandbox.
|
|
33
33
|
|
|
34
34
|
## Install
|
|
35
35
|
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
| `llm/stream` 拦截 | 该会话的下一次请求跳过该插件的监听 |
|
|
30
30
|
| 纯 UI / 全局服务 | 只提供全局开关;切换 profile bundle 并提示重启,重启后不再加载 |
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
限制:纯客户端 UI 一次 web 启动只加载一遍;插件的后台定时器/自有服务不因“关”而停止。分叉会话与子代理会先读父会话的覆盖值(父链,不复制),父会话被删除后回落到工作区。本插件是作用域管理,不是沙箱。
|
|
33
33
|
|
|
34
34
|
## 安装
|
|
35
35
|
|
package/client.js
CHANGED
|
@@ -18,6 +18,160 @@ window.__ModuleLoader__.load({
|
|
|
18
18
|
return body.data;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
function ClientUiHider({ sessionId }) {
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!sessionId) return undefined;
|
|
24
|
+
let disposed = false;
|
|
25
|
+
const sync = async () => {
|
|
26
|
+
try {
|
|
27
|
+
const state = await call({ op: 'state', sessionId });
|
|
28
|
+
if (disposed) return;
|
|
29
|
+
const hidden = [];
|
|
30
|
+
const idToPackage = new Map();
|
|
31
|
+
for (const row of (state?.rows ?? [])) {
|
|
32
|
+
for (const id of (row?.clientIds ?? [])) {
|
|
33
|
+
if (typeof id === 'string' && id) idToPackage.set(id, row.key);
|
|
34
|
+
}
|
|
35
|
+
if (row?.effective !== 'off') continue;
|
|
36
|
+
if (!row?.protected) hidden.push(row.key);
|
|
37
|
+
}
|
|
38
|
+
scopeIdToPackage = idToPackage;
|
|
39
|
+
publishScopeHidden(hidden);
|
|
40
|
+
} catch {
|
|
41
|
+
// Fail open: an unavailable scope API must never remove plugin UI.
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
sync();
|
|
45
|
+
const timer = setInterval(sync, 1500);
|
|
46
|
+
window.addEventListener('dsh-plugin-scope-changed', sync);
|
|
47
|
+
return () => {
|
|
48
|
+
disposed = true;
|
|
49
|
+
clearInterval(timer);
|
|
50
|
+
window.removeEventListener('dsh-plugin-scope-changed', sync);
|
|
51
|
+
};
|
|
52
|
+
}, [sessionId]);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// One generic layer for every React slot registration. The scope API works on
|
|
57
|
+
// package names; slot registrations expose either `key` (the package id) or an
|
|
58
|
+
// `id` derived from the package slug. Wrapping the component lets React
|
|
59
|
+
// re-render when the hidden set changes instead of relying on per-plugin CSS.
|
|
60
|
+
const scopeHidden = new Set();
|
|
61
|
+
const scopeHiddenListeners = new Set();
|
|
62
|
+
let scopeIdToPackage = new Map();
|
|
63
|
+
|
|
64
|
+
function publishScopeHidden(packages) {
|
|
65
|
+
const next = new Set((packages ?? []).filter((value) => typeof value === 'string' && value.length > 0));
|
|
66
|
+
if (next.size === scopeHidden.size && [...next].every((value) => scopeHidden.has(value))) return;
|
|
67
|
+
scopeHidden.clear();
|
|
68
|
+
for (const value of next) scopeHidden.add(value);
|
|
69
|
+
for (const listener of [...scopeHiddenListeners]) {
|
|
70
|
+
try { listener(); } catch { /* ignore one bad slot */ }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
function slotOwnedBy(options, pkg) {
|
|
76
|
+
const key = typeof options?.key === 'string' ? options.key : '';
|
|
77
|
+
const id = typeof options?.id === 'string' ? options.id : '';
|
|
78
|
+
if (key === pkg || key.startsWith(`${pkg}/`) || key.startsWith(`${pkg}:`)) return true;
|
|
79
|
+
if (id && scopeIdToPackage.get(id) === pkg) return true;
|
|
80
|
+
const slug = pkg.replace(/^@[^/]+\//, '').replace(/^dsh-/, '');
|
|
81
|
+
return id === slug || id.startsWith(`${slug}-`) || id.startsWith(`${slug}:`) || id.startsWith(`${slug}.`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function slotIsHidden(options) {
|
|
85
|
+
for (const pkg of scopeHidden) {
|
|
86
|
+
if (pkg === 'dsh-plugins-scope') continue;
|
|
87
|
+
if (slotOwnedBy(options, pkg)) return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function ScopeSlotGuard({ options, Component, ...props }) {
|
|
93
|
+
const hidden = React.useSyncExternalStore(
|
|
94
|
+
(listener) => {
|
|
95
|
+
scopeHiddenListeners.add(listener);
|
|
96
|
+
return () => scopeHiddenListeners.delete(listener);
|
|
97
|
+
},
|
|
98
|
+
() => slotIsHidden(options),
|
|
99
|
+
() => false,
|
|
100
|
+
);
|
|
101
|
+
return hidden ? null : h(Component, props);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function installSlotScopeGuard(ctx) {
|
|
105
|
+
const slots = ctx.slots;
|
|
106
|
+
if (slots === undefined || slots.__dshScopeGuard === true) return;
|
|
107
|
+
const register = slots.register;
|
|
108
|
+
if (typeof register !== 'function') return;
|
|
109
|
+
const wrap = (options, component) => {
|
|
110
|
+
return typeof component === 'function'
|
|
111
|
+
? function ScopedSlot(props) {
|
|
112
|
+
return h(ScopeSlotGuard, { ...props, options, Component: component });
|
|
113
|
+
}
|
|
114
|
+
: component;
|
|
115
|
+
};
|
|
116
|
+
slots.register = function registerScoped(options, component) {
|
|
117
|
+
return register.call(slots, options, wrap(options, component));
|
|
118
|
+
};
|
|
119
|
+
const registerFactory = slots.registerFactory;
|
|
120
|
+
if (typeof registerFactory === 'function') {
|
|
121
|
+
slots.registerFactory = function registerFactoryScoped(options, component) {
|
|
122
|
+
return registerFactory.call(slots, options, wrap(options, component));
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
// Entries registered before this plugin loaded (persona/composer controls are
|
|
126
|
+
// mounted early) never pass through the wrapper above. Wrap them lazily at the
|
|
127
|
+
// renderer's read boundary instead of keeping a per-plugin selector table.
|
|
128
|
+
const core = slots._core;
|
|
129
|
+
if (core && typeof core.entriesOfSlot === 'function' && core.__dshScopeReadGuard !== true) {
|
|
130
|
+
const entriesOfSlot = core.entriesOfSlot.bind(core);
|
|
131
|
+
core.entriesOfSlot = function scopedEntriesOfSlot(key) {
|
|
132
|
+
const entries = entriesOfSlot(key);
|
|
133
|
+
if (!Array.isArray(entries)) return entries;
|
|
134
|
+
return entries.map((entry) => {
|
|
135
|
+
if (!entry || entry.__dshScopeWrapped === true) return entry;
|
|
136
|
+
const Component = entry.component;
|
|
137
|
+
if (Component === null || Component === undefined) return entry;
|
|
138
|
+
const wrapped = function ScopedExistingSlot(props) {
|
|
139
|
+
return h(ScopeSlotGuard, { ...props, options: entry.options, Component });
|
|
140
|
+
};
|
|
141
|
+
try {
|
|
142
|
+
entry.component = wrapped;
|
|
143
|
+
entry.__dshScopeWrapped = true;
|
|
144
|
+
return entry;
|
|
145
|
+
} catch {
|
|
146
|
+
return { ...entry, component: wrapped, __dshScopeWrapped: true };
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
Object.defineProperty(core, '__dshScopeReadGuard', { value: true, enumerable: false });
|
|
151
|
+
}
|
|
152
|
+
Object.defineProperty(slots, '__dshScopeGuard', { value: true, enumerable: false });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function installContextMenuGuard(ctx) {
|
|
156
|
+
const menus = ctx.contextMenus;
|
|
157
|
+
if (menus === undefined || menus.__dshScopeGuard === true) return;
|
|
158
|
+
const register = menus.register;
|
|
159
|
+
if (typeof register !== 'function') return;
|
|
160
|
+
menus.register = function registerScopedMenu(options) {
|
|
161
|
+
const resolve = options?.resolve;
|
|
162
|
+
if (typeof resolve !== 'function') return register.call(menus, options);
|
|
163
|
+
return register.call(menus, {
|
|
164
|
+
...options,
|
|
165
|
+
resolve: async (...args) => {
|
|
166
|
+
const items = await resolve(...args);
|
|
167
|
+
if (!Array.isArray(items)) return items;
|
|
168
|
+
return items.filter((item) => !slotIsHidden({ key: item?.key, id: item?.id }));
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
Object.defineProperty(menus, '__dshScopeGuard', { value: true, enumerable: false });
|
|
173
|
+
}
|
|
174
|
+
|
|
21
175
|
const LABEL = { on: '开', off: '关' };
|
|
22
176
|
const COLOR = {
|
|
23
177
|
on: 'var(--dsw-alias-state-success-primary)',
|
|
@@ -39,7 +193,11 @@ window.__ModuleLoader__.load({
|
|
|
39
193
|
|
|
40
194
|
function sourceOf(row, level) {
|
|
41
195
|
if (!row.scoped) return '全局';
|
|
42
|
-
if (level === 'session'
|
|
196
|
+
if (level === 'session') {
|
|
197
|
+
if (row.sessionSource === 'own') return '本会话';
|
|
198
|
+
if (row.sessionSource === 'parent') return '父会话';
|
|
199
|
+
if (row.session === 'on' || row.session === 'off') return '本会话';
|
|
200
|
+
}
|
|
43
201
|
if (row.workspace === 'on' || row.workspace === 'off') return '工作区';
|
|
44
202
|
return '全局';
|
|
45
203
|
}
|
|
@@ -99,12 +257,16 @@ window.__ModuleLoader__.load({
|
|
|
99
257
|
return value === 'on' || value === 'off';
|
|
100
258
|
}
|
|
101
259
|
|
|
102
|
-
function parentName(level) {
|
|
103
|
-
|
|
260
|
+
function parentName(row, level) {
|
|
261
|
+
if (level === 'session') return row.sessionSource === 'parent' ? '父会话' : '工作区';
|
|
262
|
+
return '全局';
|
|
104
263
|
}
|
|
105
264
|
|
|
106
265
|
function parentValue(row, level) {
|
|
107
|
-
|
|
266
|
+
if (level === 'session') {
|
|
267
|
+
return row.sessionSource === 'parent' ? row.sessionEffective : row.parent;
|
|
268
|
+
}
|
|
269
|
+
return row.global;
|
|
108
270
|
}
|
|
109
271
|
|
|
110
272
|
// Copy of the shipped two-state switch: a 36x20 pill with a 14px knob.
|
|
@@ -256,7 +418,7 @@ window.__ModuleLoader__.load({
|
|
|
256
418
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: '14px' } },
|
|
257
419
|
h('div', { style: { textAlign: 'right', minWidth: '148px' } },
|
|
258
420
|
h('div', { style: { fontSize: '12px', color: theme.muted } },
|
|
259
|
-
explicit ? '本层已固定' : `跟随${parentName(level)}`),
|
|
421
|
+
explicit ? '本层已固定' : `跟随${parentName(row, level)}`),
|
|
260
422
|
h('div', { style: { marginTop: '3px', fontSize: '11px', color: theme.faint, display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: '5px' } },
|
|
261
423
|
explicit
|
|
262
424
|
? h('button', {
|
|
@@ -320,8 +482,8 @@ window.__ModuleLoader__.load({
|
|
|
320
482
|
h('div', { style: { marginTop: '3px', fontSize: '12px', color: theme.faint } },
|
|
321
483
|
isSession
|
|
322
484
|
? (state?.workspaceTitle
|
|
323
|
-
? `默认跟随工作区「${state.workspaceTitle}
|
|
324
|
-
: '
|
|
485
|
+
? `默认跟随工作区「${state.workspaceTitle}」;父会话有覆盖时跟随父会话;改动只影响这个会话。`
|
|
486
|
+
: '默认跟随工作区;父会话有覆盖时跟随父会话;改动只影响这个会话。')
|
|
325
487
|
: '默认跟随全局;改动只影响这个工作区。'),
|
|
326
488
|
),
|
|
327
489
|
h('button', {
|
|
@@ -537,7 +699,7 @@ window.__ModuleLoader__.load({
|
|
|
537
699
|
h('div', null,
|
|
538
700
|
h('div', { style: { fontSize: '15px', fontWeight: 600, color: theme.text } }, '第三方插件作用域'),
|
|
539
701
|
h('div', { style: { marginTop: '4px', color: theme.muted, lineHeight: 1.65 } },
|
|
540
|
-
'
|
|
702
|
+
'类型按插件描述自动判定:工具、模型、提示词等会随会话变化的是“会话级”;壁纸、界面、管理、远程连接类只在全局生效的是“仅全局”。远程/隧道插件固定全局,避免关掉会话时把连接通道一起关掉。开关只改“这一层”,右侧文字说明它当前是跟随上一层还是本层已固定。'),
|
|
541
703
|
message
|
|
542
704
|
? h('div', { style: { marginTop: '6px', fontSize: '12px', color: theme.warn } }, message)
|
|
543
705
|
: null,
|
|
@@ -663,6 +825,8 @@ window.__ModuleLoader__.load({
|
|
|
663
825
|
return {
|
|
664
826
|
inject: ['slots', 'contextMenus'],
|
|
665
827
|
apply(ctx) {
|
|
828
|
+
installSlotScopeGuard(ctx);
|
|
829
|
+
installContextMenuGuard(ctx);
|
|
666
830
|
ctx.slots.inject('plugins.tab', () => ctx.slots.register({
|
|
667
831
|
name: 'plugins.tab',
|
|
668
832
|
id: 'plugin-scopes',
|
|
@@ -675,6 +839,12 @@ window.__ModuleLoader__.load({
|
|
|
675
839
|
order: 30,
|
|
676
840
|
label: '插件作用域',
|
|
677
841
|
}, NewSessionScope));
|
|
842
|
+
ctx.slots.inject('conversation.input.left', () => ctx.slots.register({
|
|
843
|
+
name: 'conversation.input.left',
|
|
844
|
+
id: 'plugin-scopes-client-ui',
|
|
845
|
+
order: 900,
|
|
846
|
+
inject: (sessionId) => ({ sessionId }),
|
|
847
|
+
}, ClientUiHider));
|
|
678
848
|
ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
679
849
|
name: 'shell.overlay',
|
|
680
850
|
id: 'plugin-scopes-dialog',
|
package/docs/DETAIL.en.md
CHANGED
|
@@ -44,7 +44,7 @@ There is intentionally no manual type override, so a row can never claim to be s
|
|
|
44
44
|
|
|
45
45
|
- Client-only UI plugins load once per web boot and cannot disappear per session; only the global switch applies.
|
|
46
46
|
- Plugins that register tools dynamically at runtime (e.g. `billion-context` after connecting) keep the tool filter per session; if they also rewrite `llm/stream`, their listeners are skipped per session as well.
|
|
47
|
-
- Forked sessions and subagents
|
|
47
|
+
- Forked sessions and subagents read the parent session's overrides along the parent chain (not copied); if the parent session is deleted they fall back to the workspace.
|
|
48
48
|
- Third-party only; official plugins and the built-in manager/install/update/market are untouched.
|
|
49
49
|
|
|
50
50
|
## Install / uninstall
|
package/docs/DETAIL.md
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
|
|
45
45
|
- 纯客户端界面插件一次 web 启动只加载一遍,无法按会话消失,只能全局开关;
|
|
46
46
|
- 运行时才动态注册工具的插件(例如 `billion-context` 在连上服务后才拉取工具),工具表按会话过滤;若它同时改写 `llm/stream`,还会按会话跳过监听器;
|
|
47
|
-
-
|
|
47
|
+
- 分叉会话与子代理会沿父链读取父会话的覆盖值(不复制),删除父会话后回落到工作区;
|
|
48
48
|
- 只管理第三方插件,不动官方插件与自带安装/更新/市场。
|
|
49
49
|
|
|
50
50
|
## 安装与卸载
|
package/index.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// resolves through the same view).
|
|
12
12
|
|
|
13
13
|
import fs from 'node:fs';
|
|
14
|
+
import zlib from 'node:zlib';
|
|
14
15
|
import { randomUUID } from 'node:crypto';
|
|
15
16
|
import { createRequire } from 'node:module';
|
|
16
17
|
import os from 'node:os';
|
|
@@ -26,6 +27,8 @@ const HIDDEN_HOOK = Symbol.for('dsh.plugin-scopes.hidden-hook');
|
|
|
26
27
|
const PROMPT_PATCH_MARK = Symbol.for('dsh.plugin-scopes.prompt-patch-v2');
|
|
27
28
|
const HIDDEN_PLUGINS_HOOK = Symbol.for('dsh.plugin-scopes.hidden-plugins');
|
|
28
29
|
const SECTION_OWNERS = Symbol.for('dsh.plugin-scopes.section-owners');
|
|
30
|
+
const COMMAND_OWNERS = Symbol.for('dsh.plugin-scopes.command-owners');
|
|
31
|
+
const COMMAND_PATCH_MARK = Symbol.for('dsh.plugin-scopes.command-patch');
|
|
29
32
|
const CONTEXT_OWNERS = Symbol.for('dsh.plugin-scopes.context-owners');
|
|
30
33
|
const STREAM_PATCH_MARK = Symbol.for('dsh.plugin-scopes.stream-patch-v1');
|
|
31
34
|
const SKILL_PATCH_MARK = Symbol.for('dsh.plugin-scopes.skill-patch-v1');
|
|
@@ -109,7 +112,7 @@ function resolveProfileDir() {
|
|
|
109
112
|
const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
110
113
|
const bundles = pkg.dsh?.profile?.bundles ?? [];
|
|
111
114
|
const deps = pkg.dependencies ?? {};
|
|
112
|
-
if (bundles.includes('dsh-plugins-scope') || deps['dsh-plugins-scope'] || bundles.includes('dsh-plugin-scope') || deps['dsh-plugin-scope']) return dir;
|
|
115
|
+
if (bundles.includes('dsh-plugins-scope') || deps['dsh-plugins-scope'] || bundles.includes('dsh-plugin-scope') || deps['dsh-plugin-scope'] || bundles.includes('dsh-scope-manager') || deps['dsh-scope-manager']) return dir;
|
|
113
116
|
} catch {
|
|
114
117
|
/* not a profile */
|
|
115
118
|
}
|
|
@@ -234,7 +237,23 @@ function packageDescription(dir) {
|
|
|
234
237
|
}
|
|
235
238
|
}
|
|
236
239
|
|
|
240
|
+
const FORCE_GLOBAL_NAME = /remote|远程|relay|tunnel/i;
|
|
241
|
+
|
|
242
|
+
function packageName(dir) {
|
|
243
|
+
try {
|
|
244
|
+
return String(JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')).name || '');
|
|
245
|
+
} catch {
|
|
246
|
+
return '';
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
237
250
|
function describeScope(dir) {
|
|
251
|
+
const name = packageName(dir);
|
|
252
|
+
// Remote-access / tunnel plugins are infrastructure: turning them off for a
|
|
253
|
+
// single session would cut the very channel used to reach that session. They
|
|
254
|
+
// must stay global-only regardless of what their description says.
|
|
255
|
+
if (FORCE_GLOBAL_NAME.test(name))
|
|
256
|
+
return { decision: false, category: 'global', forceGlobal: true, reason: `远程连接/基础设施插件(${name}),固定全局` };
|
|
238
257
|
const text = packageDescription(dir);
|
|
239
258
|
if (!text) return { decision: null, category: 'unknown', reason: '没有描述' };
|
|
240
259
|
const agentHits = AGENT_HINTS.filter((word) => hintHit(text, word));
|
|
@@ -593,8 +612,87 @@ function canonicalSessionId(ctx, sessionId) {
|
|
|
593
612
|
return raw.startsWith('session-') ? raw : `session-${raw}`;
|
|
594
613
|
}
|
|
595
614
|
|
|
596
|
-
|
|
597
|
-
|
|
615
|
+
const sessionHeaderCache = new Map();
|
|
616
|
+
|
|
617
|
+
// Session#get only knows live agents; a fork that is not open (or an archived
|
|
618
|
+
// parent) is only available in its persisted header, so fall back to the log.
|
|
619
|
+
function storedSessionHeader(sessionId) {
|
|
620
|
+
const variants = [...sessionIdVariants(sessionId)];
|
|
621
|
+
for (const id of variants) {
|
|
622
|
+
if (sessionHeaderCache.has(String(id))) return sessionHeaderCache.get(String(id));
|
|
623
|
+
}
|
|
624
|
+
let header = null;
|
|
625
|
+
try {
|
|
626
|
+
const root = path.join(dshHome(), 'sessions');
|
|
627
|
+
for (const dir of fs.readdirSync(root)) {
|
|
628
|
+
for (const id of variants) {
|
|
629
|
+
const file = path.join(root, dir, id, 'session.v4.jsonl.zstd');
|
|
630
|
+
if (!fs.existsSync(file)) continue;
|
|
631
|
+
const raw = zlib.zstdDecompressSync
|
|
632
|
+
? zlib.zstdDecompressSync(fs.readFileSync(file)).toString('utf8')
|
|
633
|
+
: '';
|
|
634
|
+
const first = raw.split('\n')[0];
|
|
635
|
+
if (first) header = JSON.parse(first);
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
if (header) break;
|
|
639
|
+
}
|
|
640
|
+
} catch {
|
|
641
|
+
header = null;
|
|
642
|
+
}
|
|
643
|
+
for (const id of variants) sessionHeaderCache.set(String(id), header);
|
|
644
|
+
return header;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function sessionParentOf(ctx, sessionId) {
|
|
648
|
+
for (const id of sessionIdVariants(sessionId)) {
|
|
649
|
+
let session = null;
|
|
650
|
+
try {
|
|
651
|
+
session = ctx.sessions.get(id);
|
|
652
|
+
} catch {
|
|
653
|
+
/* fall back to the persisted header */
|
|
654
|
+
}
|
|
655
|
+
if (!session) session = storedSessionHeader(id);
|
|
656
|
+
const parent = session?.parentSession
|
|
657
|
+
?? session?.header?.parentSession
|
|
658
|
+
?? session?.meta?.parentSession;
|
|
659
|
+
if (parent) return String(parent);
|
|
660
|
+
}
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// A forked session inherits its parent's own override; a subagent inherits the
|
|
665
|
+
// session that spawned it. Read the chain instead of copying values, so a later
|
|
666
|
+
// change on the parent is still visible to the child.
|
|
667
|
+
function sessionValueChain(ctx, store, sessionId, key) {
|
|
668
|
+
const seen = new Set();
|
|
669
|
+
let current = sessionId;
|
|
670
|
+
let depth = 0;
|
|
671
|
+
while (current && depth < 32) {
|
|
672
|
+
const ids = [...sessionIdVariants(current)].filter((id) => !seen.has(String(id)));
|
|
673
|
+
if (ids.length === 0) break;
|
|
674
|
+
for (const id of ids) {
|
|
675
|
+
seen.add(String(id));
|
|
676
|
+
const value = levelValue(store.sessions[id], key);
|
|
677
|
+
if (value !== 'inherit') return { value, source: depth === 0 ? 'own' : 'parent' };
|
|
678
|
+
}
|
|
679
|
+
current = sessionParentOf(ctx, current);
|
|
680
|
+
depth += 1;
|
|
681
|
+
}
|
|
682
|
+
return { value: 'inherit', source: null };
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// What this session would inherit if its own override were removed. Kept
|
|
686
|
+
// separate from sessionValueChain so an explicit child override still shows the
|
|
687
|
+
// real parent value in the UI.
|
|
688
|
+
function sessionInheritedValue(ctx, store, sessionId, key) {
|
|
689
|
+
const parent = sessionParentOf(ctx, sessionId);
|
|
690
|
+
if (!parent) return 'inherit';
|
|
691
|
+
return sessionValueChain(ctx, store, parent, key).value;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function effective(ctx, store, key, workspaceId, sessionId) {
|
|
695
|
+
const session = sessionId ? sessionValueChain(ctx, store, sessionId, key).value : 'inherit';
|
|
598
696
|
if (session !== 'inherit') return session;
|
|
599
697
|
const workspace = workspaceId ? levelValue(store.workspaces[workspaceId], key) : 'inherit';
|
|
600
698
|
if (workspace !== 'inherit') return workspace;
|
|
@@ -658,6 +756,53 @@ function makeService(ctx) {
|
|
|
658
756
|
return names;
|
|
659
757
|
}
|
|
660
758
|
|
|
759
|
+
function clientSlotIds(dir) {
|
|
760
|
+
const files = ['client.js', 'lib/client.js', 'dist/client.js', 'client/index.js'];
|
|
761
|
+
const ids = new Set();
|
|
762
|
+
let source = '';
|
|
763
|
+
for (const file of files) {
|
|
764
|
+
try { source = fs.readFileSync(path.join(dir, file), 'utf8'); break; } catch { /* try next entry */ }
|
|
765
|
+
}
|
|
766
|
+
if (!source) return [];
|
|
767
|
+
// Client UI is registered through `ctx.slots.register/inject({ id, key, name }, ...)`.
|
|
768
|
+
// The id is stable per entry, so scan it once per package instead of asking the
|
|
769
|
+
// user (or the plugin author) to maintain a per-plugin DOM selector.
|
|
770
|
+
for (const call of source.matchAll(/slots\.(?:register|registerFactory|inject)\s*\(/g)) {
|
|
771
|
+
const tail = source.slice(call.index, call.index + 900);
|
|
772
|
+
const id = tail.match(/\bid\s*:\s*['"]([^'"]+)['"]/);
|
|
773
|
+
if (id?.[1]) ids.add(id[1]);
|
|
774
|
+
const key = tail.match(/\bkey\s*:\s*['"]([^'"]+)['"]/);
|
|
775
|
+
if (key?.[1]) ids.add(key[1]);
|
|
776
|
+
}
|
|
777
|
+
return [...ids];
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
function commandNames(dir) {
|
|
781
|
+
const names = new Set();
|
|
782
|
+
for (const file of walkSources(dir)) {
|
|
783
|
+
let text;
|
|
784
|
+
try {
|
|
785
|
+
if (fs.statSync(file).size > 8_000_000) continue;
|
|
786
|
+
text = fs.readFileSync(file, 'utf8');
|
|
787
|
+
} catch { continue; }
|
|
788
|
+
for (const call of text.matchAll(/\.register\s*\(\s*\{/g)) {
|
|
789
|
+
const head = text.slice(Math.max(0, call.index - 120), call.index);
|
|
790
|
+
if (!/commands/.test(head)) continue;
|
|
791
|
+
const tail = text.slice(call.index, call.index + 700);
|
|
792
|
+
const name = tail.match(/\bname\s*:\s*['"]([^'"]+)['"]/);
|
|
793
|
+
if (name?.[1]) names.add(name[1]);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return [...names];
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function staticCommandOwner(name) {
|
|
800
|
+
for (const row of rowsCached()) {
|
|
801
|
+
if ((row.commands ?? []).includes(name)) return row.key;
|
|
802
|
+
}
|
|
803
|
+
return undefined;
|
|
804
|
+
}
|
|
805
|
+
|
|
661
806
|
function buildRows() {
|
|
662
807
|
const { deps, bundles } = profileDeps();
|
|
663
808
|
const base = baseToolNames();
|
|
@@ -684,7 +829,7 @@ function makeService(ctx) {
|
|
|
684
829
|
const runtimeContexts = attrStore().contexts.get(pkg);
|
|
685
830
|
const contexts = runtimeContexts?.size ? [...new Set([...staticContexts, ...runtimeContexts.keys()])] : staticContexts;
|
|
686
831
|
const capability = tools.length > 0 || prompts.length > 0 || contexts.length > 0;
|
|
687
|
-
const scoped = PROTECTED.has(pkg) ? false : (desc.decision ?? capability);
|
|
832
|
+
const scoped = PROTECTED.has(pkg) || desc.forceGlobal ? false : (desc.decision ?? capability);
|
|
688
833
|
const axes = [tools.length, prompts.length, contexts.length].filter((count) => count > 0).length;
|
|
689
834
|
const kind = !capability ? 'global' : axes > 1 ? 'mixed' : tools.length > 0 ? 'tools' : prompts.length > 0 ? 'prompt' : 'context';
|
|
690
835
|
rows.push({
|
|
@@ -700,6 +845,9 @@ function makeService(ctx) {
|
|
|
700
845
|
category: PROTECTED.has(pkg) ? 'global' : desc.category,
|
|
701
846
|
reason: PROTECTED.has(pkg) ? '基础插件,不参与作用域' : desc.reason,
|
|
702
847
|
protected: PROTECTED.has(pkg),
|
|
848
|
+
forceGlobal: desc.forceGlobal === true,
|
|
849
|
+
clientIds: clientSlotIds(dir),
|
|
850
|
+
commands: commandNames(dir),
|
|
703
851
|
});
|
|
704
852
|
}
|
|
705
853
|
// Central attribution pass: observed tool names that no row has claimed yet
|
|
@@ -736,7 +884,7 @@ function makeService(ctx) {
|
|
|
736
884
|
}
|
|
737
885
|
for (const row of rows) {
|
|
738
886
|
row.capability = row.tools.length > 0 || row.promptSections.length > 0 || (row.promptContexts?.length ?? 0) > 0;
|
|
739
|
-
row.scoped = !row.protected && (row.descScope === true || row.capability);
|
|
887
|
+
row.scoped = !row.protected && !row.forceGlobal && (row.descScope === true || row.capability);
|
|
740
888
|
const axes = [row.tools.length, row.promptSections.length, row.promptContexts?.length ?? 0].filter((count) => count > 0).length;
|
|
741
889
|
row.kind = !row.capability ? 'global' : axes > 1 ? 'mixed' : row.tools.length > 0 ? 'tools' : row.promptSections.length > 0 ? 'prompt' : 'context';
|
|
742
890
|
}
|
|
@@ -765,7 +913,7 @@ function makeService(ctx) {
|
|
|
765
913
|
for (const row of rows) {
|
|
766
914
|
if (!row.capability) continue;
|
|
767
915
|
const value = row.scoped
|
|
768
|
-
? effective(store, row.key, workspaceId, sessionId)
|
|
916
|
+
? effective(ctx, store, row.key, workspaceId, sessionId)
|
|
769
917
|
: levelValue(store.global, row.key) === 'inherit'
|
|
770
918
|
? 'on'
|
|
771
919
|
: levelValue(store.global, row.key);
|
|
@@ -787,7 +935,7 @@ function makeService(ctx) {
|
|
|
787
935
|
const packages = []
|
|
788
936
|
for (const row of rows) {
|
|
789
937
|
if (!row.scoped || !managed.has(row.key)) continue
|
|
790
|
-
if (effective(store, row.key, workspaceId, sessionId) === 'on') packages.push(row.key)
|
|
938
|
+
if (effective(ctx, store, row.key, workspaceId, sessionId) === 'on') packages.push(row.key)
|
|
791
939
|
}
|
|
792
940
|
return packages
|
|
793
941
|
}
|
|
@@ -886,12 +1034,16 @@ function makeService(ctx) {
|
|
|
886
1034
|
|
|
887
1035
|
function hiddenPluginsForSession(sessionId, store) {
|
|
888
1036
|
const rows = rowsCached();
|
|
889
|
-
|
|
1037
|
+
// Agent ids are commonly `session-<uuid>` while storage keys use the bare
|
|
1038
|
+
// uuid. Normalize once so every capability (tools, prompts, skills,
|
|
1039
|
+
// commands, stream hooks) sees the same override.
|
|
1040
|
+
const sid = canonicalSessionId(ctx, sessionId) ?? sessionId;
|
|
1041
|
+
const workspaceId = workspaceIdForSession(sid);
|
|
890
1042
|
const hidden = new Set();
|
|
891
1043
|
for (const row of rows) {
|
|
892
1044
|
if (!row.capability) continue;
|
|
893
1045
|
const value = row.scoped
|
|
894
|
-
? effective(store, row.key, workspaceId, sessionId)
|
|
1046
|
+
? effective(ctx, store, row.key, workspaceId, sessionId)
|
|
895
1047
|
: levelValue(store.global, row.key) === 'inherit'
|
|
896
1048
|
? 'on'
|
|
897
1049
|
: levelValue(store.global, row.key);
|
|
@@ -905,11 +1057,12 @@ function makeService(ctx) {
|
|
|
905
1057
|
// skipped for sessions where the row is off. Only session-scoped rows qualify.
|
|
906
1058
|
function hiddenPackagesForSession(sessionId, store) {
|
|
907
1059
|
const rows = rowsCached();
|
|
908
|
-
const
|
|
1060
|
+
const sid = canonicalSessionId(ctx, sessionId) ?? sessionId;
|
|
1061
|
+
const workspaceId = workspaceIdForSession(sid);
|
|
909
1062
|
const hidden = new Set();
|
|
910
1063
|
for (const row of rows) {
|
|
911
1064
|
if (!row.scoped) continue;
|
|
912
|
-
if (effective(store, row.key, workspaceId,
|
|
1065
|
+
if (effective(ctx, store, row.key, workspaceId, sid) === 'off') hidden.add(row.key);
|
|
913
1066
|
}
|
|
914
1067
|
return hidden;
|
|
915
1068
|
}
|
|
@@ -1028,6 +1181,65 @@ function makeService(ctx) {
|
|
|
1028
1181
|
}
|
|
1029
1182
|
}
|
|
1030
1183
|
|
|
1184
|
+
function commandOwnerMap() {
|
|
1185
|
+
if (!globalThis[COMMAND_OWNERS]) globalThis[COMMAND_OWNERS] = new Map();
|
|
1186
|
+
return globalThis[COMMAND_OWNERS];
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// Commands are a separate capability from tools/prompts: a plugin can be off
|
|
1190
|
+
// for a session yet still be discoverable in the slash menu unless the
|
|
1191
|
+
// command runtime is filtered too. Attribute registration by stack, then
|
|
1192
|
+
// filter list/find/execute for the exact agent.
|
|
1193
|
+
function installCommandFilter() {
|
|
1194
|
+
const commands = ctx.get?.('commands');
|
|
1195
|
+
if (!commands) return;
|
|
1196
|
+
const proto = Object.getPrototypeOf(commands);
|
|
1197
|
+
if (!proto || proto[COMMAND_PATCH_MARK]) return;
|
|
1198
|
+
const originalRegister = proto.register;
|
|
1199
|
+
if (typeof originalRegister !== 'function') return;
|
|
1200
|
+
Object.defineProperty(proto, COMMAND_PATCH_MARK, { value: true, enumerable: false });
|
|
1201
|
+
proto.register = function patchedCommandRegister(definition) {
|
|
1202
|
+
try {
|
|
1203
|
+
const pkg = packageFromStack(new Error().stack);
|
|
1204
|
+
if (definition?.name && pkg) commandOwnerMap().set(String(definition.name), pkg);
|
|
1205
|
+
} catch { /* attribution is best effort */ }
|
|
1206
|
+
return originalRegister.call(this, definition);
|
|
1207
|
+
};
|
|
1208
|
+
const originalList = proto.list;
|
|
1209
|
+
if (typeof originalList === 'function') {
|
|
1210
|
+
proto.list = function patchedCommandList(agent) {
|
|
1211
|
+
const list = originalList.call(this, agent);
|
|
1212
|
+
try {
|
|
1213
|
+
const hidden = hiddenPluginsForSession(agent?.id, readStore());
|
|
1214
|
+
if (!hidden.size) return list;
|
|
1215
|
+
const owners = commandOwnerMap();
|
|
1216
|
+
return list.filter((item) => !hidden.has(owners.get(String(item.name)) ?? staticCommandOwner(String(item.name))));
|
|
1217
|
+
} catch { return list; }
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
const originalFind = proto.find;
|
|
1221
|
+
if (typeof originalFind === 'function') {
|
|
1222
|
+
proto.find = function patchedCommandFind(agent, name) {
|
|
1223
|
+
try {
|
|
1224
|
+
const hidden = hiddenPluginsForSession(agent?.id, readStore());
|
|
1225
|
+
if (hidden.has(commandOwnerMap().get(String(name)) ?? staticCommandOwner(String(name)))) return undefined;
|
|
1226
|
+
} catch { /* never break lookup */ }
|
|
1227
|
+
return originalFind.call(this, agent, name);
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
const originalExecute = proto.execute;
|
|
1231
|
+
if (typeof originalExecute === 'function') {
|
|
1232
|
+
proto.execute = function patchedCommandExecute(agent, line, ...rest) {
|
|
1233
|
+
try {
|
|
1234
|
+
const name = String(line).replace(/^\//, '').trim().split(/\s+/, 1)[0];
|
|
1235
|
+
const hidden = hiddenPluginsForSession(agent?.id, readStore());
|
|
1236
|
+
if (hidden.has(commandOwnerMap().get(name) ?? staticCommandOwner(name))) return undefined;
|
|
1237
|
+
} catch { /* never break execution */ }
|
|
1238
|
+
return originalExecute.call(this, agent, line, ...rest);
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1031
1243
|
function installSectionFilter() {
|
|
1032
1244
|
const proto = Object.getPrototypeOf(ctx.systemPrompt);
|
|
1033
1245
|
if (!proto) return;
|
|
@@ -1088,6 +1300,15 @@ function makeService(ctx) {
|
|
|
1088
1300
|
const owners = sectionOwnerMap();
|
|
1089
1301
|
const staticOwners = staticSectionOwners(rowsCached());
|
|
1090
1302
|
const sections = (assembly.sections ?? []).filter((section) => {
|
|
1303
|
+
const name = String(section.name ?? '');
|
|
1304
|
+
// A plugin can inject a section directly into the assembled prompt
|
|
1305
|
+
// without registering it through systemPrompt.section (dsh-purge does
|
|
1306
|
+
// exactly that). Its section name is still the package name, so match
|
|
1307
|
+
// it against hidden packages as a last line of defence.
|
|
1308
|
+
if (hidden.has(name)) return false;
|
|
1309
|
+
for (const pkg of hidden) {
|
|
1310
|
+
if (name.startsWith(`${pkg}:`) || name.startsWith(`${pkg}/`)) return false;
|
|
1311
|
+
}
|
|
1091
1312
|
const owner = owners.get(section.name);
|
|
1092
1313
|
if (owner && matchesHidden(owner, hidden)) return false;
|
|
1093
1314
|
const key = staticOwners.get(section.name);
|
|
@@ -1096,6 +1317,11 @@ function makeService(ctx) {
|
|
|
1096
1317
|
const contextOwners = contextOwnerMap();
|
|
1097
1318
|
const staticContexts = staticContextOwners(rowsCached());
|
|
1098
1319
|
const contexts = (assembly.contexts ?? []).filter((entry) => {
|
|
1320
|
+
const name = String(entry.name ?? '');
|
|
1321
|
+
if (hidden.has(name)) return false;
|
|
1322
|
+
for (const pkg of hidden) {
|
|
1323
|
+
if (name.startsWith(`${pkg}:`) || name.startsWith(`${pkg}/`)) return false;
|
|
1324
|
+
}
|
|
1099
1325
|
const owner = contextOwners.get(entry.name);
|
|
1100
1326
|
if (owner && matchesHidden(owner, hidden)) return false;
|
|
1101
1327
|
const key = staticContexts.get(entry.name);
|
|
@@ -1147,6 +1373,7 @@ function makeService(ctx) {
|
|
|
1147
1373
|
const thisArg =
|
|
1148
1374
|
args.length > 0 && (typeof args[0] === 'object' || typeof args[0] === 'function') ? args[0] : null;
|
|
1149
1375
|
const nameIndex = thisArg ? 1 : 0;
|
|
1376
|
+
if (args[nameIndex] === 'system-prompt/assemble') return original.apply(this, args);
|
|
1150
1377
|
if (args[nameIndex] !== 'llm/stream') return original.apply(this, args);
|
|
1151
1378
|
const inner = args[args.length - 1];
|
|
1152
1379
|
const listenerArgs = args.slice(nameIndex + 1, args.length - 1);
|
|
@@ -1219,6 +1446,8 @@ function makeService(ctx) {
|
|
|
1219
1446
|
managed: managedSet.has(row.key),
|
|
1220
1447
|
composable: row.scoped && !composable(row.key),
|
|
1221
1448
|
tools: row.tools,
|
|
1449
|
+
clientIds: row.clientIds ?? [],
|
|
1450
|
+
commands: row.commands ?? [],
|
|
1222
1451
|
promptSections: [],
|
|
1223
1452
|
promptContexts: [],
|
|
1224
1453
|
global: on ? 'on' : 'off',
|
|
@@ -1232,13 +1461,29 @@ function makeService(ctx) {
|
|
|
1232
1461
|
const scopedWorkspaceId = resolvedWorkspaceId;
|
|
1233
1462
|
const w = editable && scopedWorkspaceId ? levelValue(store.workspaces[scopedWorkspaceId], row.key) : 'inherit';
|
|
1234
1463
|
const s = editable && sessionId ? sessionValue(store, sessionId, row.key) : 'inherit';
|
|
1235
|
-
const
|
|
1464
|
+
const chain = editable && sessionId
|
|
1465
|
+
? sessionValueChain(ctx, store, sessionId, row.key)
|
|
1466
|
+
: { value: 'inherit', source: null };
|
|
1467
|
+
const resolved = editable ? effective(ctx, store, row.key, scopedWorkspaceId, sessionId) : g === 'inherit' ? 'on' : g;
|
|
1236
1468
|
const globalEffective = g === 'inherit' ? 'on' : g;
|
|
1237
1469
|
const workspaceEffective = w === 'inherit' ? globalEffective : w;
|
|
1238
|
-
|
|
1470
|
+
// When a fork inherits a parent-session override, the "previous level"
|
|
1471
|
+
// shown in the UI is that parent value; otherwise it remains the workspace.
|
|
1472
|
+
const sessionParentValue = editable && sessionId
|
|
1473
|
+
? sessionInheritedValue(ctx, store, sessionId, row.key)
|
|
1474
|
+
: 'inherit';
|
|
1475
|
+
const sessionEffective = chain.value === 'inherit' ? workspaceEffective : chain.value;
|
|
1476
|
+
const sessionSource = s !== 'inherit' ? 'own' : (chain.source === 'parent' ? 'parent' : 'workspace');
|
|
1477
|
+
const parent = editable
|
|
1478
|
+
? (sessionId
|
|
1479
|
+
? (sessionParentValue !== 'inherit' ? sessionParentValue : workspaceEffective)
|
|
1480
|
+
: workspaceId ? globalEffective : undefined)
|
|
1481
|
+
: undefined;
|
|
1239
1482
|
return {
|
|
1240
1483
|
key: row.key,
|
|
1241
1484
|
name: row.name,
|
|
1485
|
+
clientIds: row.clientIds ?? [],
|
|
1486
|
+
commands: row.commands ?? [],
|
|
1242
1487
|
scoped: row.scoped,
|
|
1243
1488
|
capability: row.capability,
|
|
1244
1489
|
kind: row.kind,
|
|
@@ -1253,6 +1498,9 @@ function makeService(ctx) {
|
|
|
1253
1498
|
global: g === 'inherit' ? 'on' : g,
|
|
1254
1499
|
workspace: w,
|
|
1255
1500
|
session: s,
|
|
1501
|
+
sessionEffective,
|
|
1502
|
+
sessionSource,
|
|
1503
|
+
sessionParentValue,
|
|
1256
1504
|
parent,
|
|
1257
1505
|
effective: resolved,
|
|
1258
1506
|
};
|
|
@@ -1272,7 +1520,7 @@ function makeService(ctx) {
|
|
|
1272
1520
|
workspaces,
|
|
1273
1521
|
managed: store.managed,
|
|
1274
1522
|
storage: storageFile(),
|
|
1275
|
-
build: '
|
|
1523
|
+
build: 'v10',
|
|
1276
1524
|
sessionId: sessionId ?? null,
|
|
1277
1525
|
workspaceId: resolvedWorkspaceId ?? null,
|
|
1278
1526
|
workspaceTitle: workspaceRecord?.title ?? null,
|
|
@@ -1335,6 +1583,11 @@ function makeService(ctx) {
|
|
|
1335
1583
|
}
|
|
1336
1584
|
writeStore(store);
|
|
1337
1585
|
cache.delete('rows');
|
|
1586
|
+
// A scope change alters the effective slash-command list without
|
|
1587
|
+
// registering/unregistering anything. Notify observers so an open composer
|
|
1588
|
+
// refetches instead of showing a stale command until reload.
|
|
1589
|
+
try { ctx.emit?.('commands/change'); } catch { /* event surface may differ */ }
|
|
1590
|
+
try { ctx.get?.('commands')?.emit?.('commands/change'); } catch { /* best effort */ }
|
|
1338
1591
|
return stateFor({ workspaceId: level === 'workspace' ? id : undefined, sessionId: level === 'session' ? id : undefined });
|
|
1339
1592
|
}
|
|
1340
1593
|
|
|
@@ -1508,7 +1761,7 @@ function makeService(ctx) {
|
|
|
1508
1761
|
throw new Error(`unknown op ${op}`);
|
|
1509
1762
|
}
|
|
1510
1763
|
|
|
1511
|
-
return { collectObserved, rowsCached, stateFor, setValue, handleRequest, hiddenByName, installResolveFilter, installSectionFilter, installSkillFilter, installStreamFilter, installComposeMount };
|
|
1764
|
+
return { collectObserved, rowsCached, stateFor, setValue, handleRequest, hiddenByName, installResolveFilter, installSectionFilter, installCommandFilter, installSkillFilter, installStreamFilter, installComposeMount };
|
|
1512
1765
|
}
|
|
1513
1766
|
|
|
1514
1767
|
export function apply(ctx) {
|
|
@@ -1520,6 +1773,7 @@ export function apply(ctx) {
|
|
|
1520
1773
|
}
|
|
1521
1774
|
try {
|
|
1522
1775
|
service.installSectionFilter();
|
|
1776
|
+
try { service.installCommandFilter(); } catch { /* keep the plugin usable even if command filtering cannot be installed */ }
|
|
1523
1777
|
} catch {
|
|
1524
1778
|
/* keep the plugin usable even if prompt filtering cannot be installed */
|
|
1525
1779
|
}
|