dsh-hiss-plugins 1.4.0 → 1.5.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 +11 -5
- package/lib/client.js +375 -7
- package/lib/project-mcp/actions.js +60 -0
- package/lib/project-mcp/config.js +119 -1
- package/lib/project-mcp/index.js +429 -23
- package/lib/project-mcp/state.js +154 -0
- package/lib/project-mcp/view.js +109 -0
- package/locale/en.json +33 -1
- package/locale/zh.json +33 -1
- package/package.json +3 -2
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `/mcp` dialog view: one pure function that turns what the session sees into
|
|
3
|
+
* the two columns the dialog draws, so the host seam stays thin and every
|
|
4
|
+
* attribution rule is testable without a host.
|
|
5
|
+
*
|
|
6
|
+
* @module dsh-hiss-plugins/project-mcp/view
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Prefix the bridge puts on every tool it registers. */
|
|
10
|
+
const MCP_PREFIX = "mcp__";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The server that owns one tool name, longest declared name first. The bridge never
|
|
14
|
+
* parses a tool name back (both halves may contain underscores), so ownership is a
|
|
15
|
+
* prefix match against the servers this session actually declares.
|
|
16
|
+
* @param {string} toolName - the public tool name.
|
|
17
|
+
* @param {string[]} names - server names, longest first.
|
|
18
|
+
* @returns {string | undefined} the owner, or undefined when nothing declares it.
|
|
19
|
+
*/
|
|
20
|
+
function ownerOf(toolName, names) {
|
|
21
|
+
return names.find((name) => toolName.startsWith(`${MCP_PREFIX}${name}__`));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The server a tool belongs to: its declared owner, else the first segment after the prefix.
|
|
26
|
+
* @param {string} toolName - the public tool name.
|
|
27
|
+
* @param {string[]} names - declared server names.
|
|
28
|
+
* @returns {string} the server name used in the dialog.
|
|
29
|
+
*/
|
|
30
|
+
function serverOf(toolName, names) {
|
|
31
|
+
const owner = ownerOf(toolName, names);
|
|
32
|
+
if (owner !== undefined) return owner;
|
|
33
|
+
const [first = ""] = toolName.slice(MCP_PREFIX.length).split("__");
|
|
34
|
+
return first;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Sort server entries by name, then their tools by name. */
|
|
38
|
+
function sorted(entries) {
|
|
39
|
+
return entries
|
|
40
|
+
.map((entry) => ({ ...entry, tools: [...entry.tools].sort((left, right) => (left.name < right.name ? -1 : 1)) }))
|
|
41
|
+
.sort((left, right) => (left.name < right.name ? -1 : 1));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Build the dialog view.
|
|
46
|
+
*
|
|
47
|
+
* Attribution answers one question: which column owns a tool right now? A tool
|
|
48
|
+
* belongs to the workspace only while its declared copy is mounted; a switched-off
|
|
49
|
+
* workspace copy is unmounted, so a same-named global server receives its tools.
|
|
50
|
+
* That is what makes "register globally" land in the global column immediately.
|
|
51
|
+
*
|
|
52
|
+
* @param {object} input - what the session currently holds.
|
|
53
|
+
* @param {string} input.cwd - the session workspace directory.
|
|
54
|
+
* @param {string[]} [input.toolNames] - tools the agent can see right now.
|
|
55
|
+
* @param {{ name: string, managed?: boolean, enabled?: boolean }[]} [input.globalServers]
|
|
56
|
+
* servers configured outside this workspace, with the manager state when known.
|
|
57
|
+
* @param {string[]} [input.workspaceServers] - server names this workspace declares.
|
|
58
|
+
* @param {string[]} [input.disabledTools] - tools this workspace switched off.
|
|
59
|
+
* @param {string[]} [input.disabledServers] - workspace servers this workspace switched off.
|
|
60
|
+
* @returns {{ cwd: string, global: object[], local: object[] }} the two columns.
|
|
61
|
+
*/
|
|
62
|
+
export function buildView({ cwd, toolNames = [], globalServers = [], workspaceServers = [], disabledTools = [], disabledServers = [] }) {
|
|
63
|
+
const localEnabled = workspaceServers.filter((name) => !disabledServers.includes(name));
|
|
64
|
+
const globalByName = new Map(globalServers.map((entry) => [entry.name, entry]));
|
|
65
|
+
const declared = [...new Set([...localEnabled, ...globalByName.keys()])].sort((left, right) => right.length - left.length);
|
|
66
|
+
const globalTools = new Map([...globalByName.keys()].map((name) => [name, []]));
|
|
67
|
+
const localTools = new Map(localEnabled.map((name) => [name, []]));
|
|
68
|
+
const visible = new Set(toolNames.filter((name) => name.startsWith(MCP_PREFIX)));
|
|
69
|
+
// A switched-off tool is no longer visible, so the remembered name is what keeps its row alive.
|
|
70
|
+
for (const name of [...visible, ...disabledTools.filter((tool) => !visible.has(tool))]) {
|
|
71
|
+
if (!name.startsWith(MCP_PREFIX)) continue;
|
|
72
|
+
const server = serverOf(name, declared);
|
|
73
|
+
const row = { name, enabled: !disabledTools.includes(name) };
|
|
74
|
+
if (localTools.has(server)) localTools.get(server).push(row);
|
|
75
|
+
else if (globalTools.has(server)) globalTools.get(server).push(row);
|
|
76
|
+
else globalTools.set(server, [row]);
|
|
77
|
+
}
|
|
78
|
+
const global = sorted([...globalByName.entries()].map(([name, entry]) => ({
|
|
79
|
+
name,
|
|
80
|
+
managed: entry.managed === true,
|
|
81
|
+
enabled: entry.enabled !== false,
|
|
82
|
+
tools: globalTools.get(name) ?? [],
|
|
83
|
+
})));
|
|
84
|
+
for (const [name, tools] of globalTools) {
|
|
85
|
+
if (globalByName.has(name)) continue;
|
|
86
|
+
global.push({ name, managed: false, enabled: true, tools });
|
|
87
|
+
}
|
|
88
|
+
const local = sorted(workspaceServers.map((name) => ({
|
|
89
|
+
name,
|
|
90
|
+
enabled: localEnabled.includes(name),
|
|
91
|
+
tools: localTools.get(name) ?? [],
|
|
92
|
+
})));
|
|
93
|
+
return { cwd, global: sorted(global), local };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The tools one workspace has switched off that still exist globally.
|
|
98
|
+
*
|
|
99
|
+
* `tools.restrict` refuses a name it cannot see, so a remembered name that no
|
|
100
|
+
* longer exists (a server removed, a project tool) must be dropped here instead
|
|
101
|
+
* of failing the whole restriction.
|
|
102
|
+
* @param {string[]} disabledTools - the workspace switch list.
|
|
103
|
+
* @param {string[]} globalNames - names currently registered in the global view.
|
|
104
|
+
* @returns {string[]} the usable deny set, without duplicates.
|
|
105
|
+
*/
|
|
106
|
+
export function denyFor(disabledTools, globalNames) {
|
|
107
|
+
const known = new Set(globalNames);
|
|
108
|
+
return [...new Set(disabledTools)].filter((name) => known.has(name));
|
|
109
|
+
}
|
package/locale/en.json
CHANGED
|
@@ -34,5 +34,37 @@
|
|
|
34
34
|
"lanFailed": "Could not enable LAN access: {error}",
|
|
35
35
|
"lanNotInstalled": "This profile has no lan-access row.",
|
|
36
36
|
"lanReadOnly": "The lan-access row cannot be enabled from here ({reason}).",
|
|
37
|
-
"lanFrameFailed": "The QR page did not answer; open /lan-access to see why."
|
|
37
|
+
"lanFrameFailed": "The QR page did not answer; open /lan-access to see why.",
|
|
38
|
+
"mcpTitle": "MCP servers",
|
|
39
|
+
"mcpClose": "Close",
|
|
40
|
+
"mcpLoading": "Reading MCP state…",
|
|
41
|
+
"mcpFailed": "The operation failed: {error}",
|
|
42
|
+
"mcpGlobal": "Global MCP",
|
|
43
|
+
"mcpLocal": "Workspace MCP",
|
|
44
|
+
"mcpNoGlobal": "No global MCP servers.",
|
|
45
|
+
"mcpNoLocal": "This workspace declares no .mcp.json servers.",
|
|
46
|
+
"mcpNoTools": "No tools (not connected, or the server exposes none).",
|
|
47
|
+
"mcpConnected": "Connected",
|
|
48
|
+
"mcpNotConnected": "Not connected",
|
|
49
|
+
"mcpToolToggle": "Toggle {name}",
|
|
50
|
+
"mcpServerToggle": "Toggle server {name}",
|
|
51
|
+
"mcpPromote": "Register globally",
|
|
52
|
+
"mcpAddTitle": "Add an MCP server",
|
|
53
|
+
"mcpAddName": "Name",
|
|
54
|
+
"mcpAddScope": "Scope",
|
|
55
|
+
"mcpAddGlobal": "Global (every session)",
|
|
56
|
+
"mcpAddWorkspace": "This workspace",
|
|
57
|
+
"mcpAddType": "Type",
|
|
58
|
+
"mcpAddStdio": "stdio (a command)",
|
|
59
|
+
"mcpAddHttp": "http (a URL)",
|
|
60
|
+
"mcpAddCommand": "Command",
|
|
61
|
+
"mcpAddArgs": "Arguments (space separated)",
|
|
62
|
+
"mcpAddUrl": "URL",
|
|
63
|
+
"mcpAddSubmit": "Add",
|
|
64
|
+
"mcpRefresh": "Refresh",
|
|
65
|
+
"mcpAdd": "Add MCP",
|
|
66
|
+
"mcpExpand": "{count} tools",
|
|
67
|
+
"mcpCollapse": "Collapse",
|
|
68
|
+
"mcpExpandAria": "Expand the tools of {name}",
|
|
69
|
+
"mcpCollapseAria": "Collapse the tools of {name}"
|
|
38
70
|
}
|
package/locale/zh.json
CHANGED
|
@@ -34,5 +34,37 @@
|
|
|
34
34
|
"lanFailed": "无法开启局域网访问:{error}",
|
|
35
35
|
"lanNotInstalled": "这个 profile 里没有 lan-access 行。",
|
|
36
36
|
"lanReadOnly": "无法在这个页面启用 lan-access 行({reason})。",
|
|
37
|
-
"lanFrameFailed": "二维码页没有响应;请先打开 /lan-access 检查原因。"
|
|
37
|
+
"lanFrameFailed": "二维码页没有响应;请先打开 /lan-access 检查原因。",
|
|
38
|
+
"mcpTitle": "MCP 服务器",
|
|
39
|
+
"mcpClose": "关闭",
|
|
40
|
+
"mcpLoading": "正在读取 MCP 状态…",
|
|
41
|
+
"mcpFailed": "操作失败:{error}",
|
|
42
|
+
"mcpGlobal": "全局 MCP",
|
|
43
|
+
"mcpLocal": "当前工作区 MCP",
|
|
44
|
+
"mcpNoGlobal": "没有全局 MCP 服务器。",
|
|
45
|
+
"mcpNoLocal": "这个工作区没有 .mcp.json 服务器。",
|
|
46
|
+
"mcpNoTools": "没有工具(未连接,或服务器没有工具)。",
|
|
47
|
+
"mcpConnected": "已连接",
|
|
48
|
+
"mcpNotConnected": "未连接",
|
|
49
|
+
"mcpToolToggle": "开关 {name}",
|
|
50
|
+
"mcpServerToggle": "开关服务器 {name}",
|
|
51
|
+
"mcpPromote": "注册到全局",
|
|
52
|
+
"mcpAddTitle": "新增 MCP 服务器",
|
|
53
|
+
"mcpAddName": "名称",
|
|
54
|
+
"mcpAddScope": "作用域",
|
|
55
|
+
"mcpAddGlobal": "全局(所有会话)",
|
|
56
|
+
"mcpAddWorkspace": "当前工作区",
|
|
57
|
+
"mcpAddType": "类型",
|
|
58
|
+
"mcpAddStdio": "stdio(启动命令)",
|
|
59
|
+
"mcpAddHttp": "http(URL)",
|
|
60
|
+
"mcpAddCommand": "命令",
|
|
61
|
+
"mcpAddArgs": "参数(空格分隔)",
|
|
62
|
+
"mcpAddUrl": "URL",
|
|
63
|
+
"mcpAddSubmit": "添加",
|
|
64
|
+
"mcpRefresh": "刷新",
|
|
65
|
+
"mcpAdd": "添加 MCP",
|
|
66
|
+
"mcpExpand": "{count} 个工具",
|
|
67
|
+
"mcpCollapse": "收起",
|
|
68
|
+
"mcpExpandAria": "展开 {name} 的工具",
|
|
69
|
+
"mcpCollapseAria": "收起 {name} 的工具"
|
|
38
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hiss-plugins",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "dsh-hiss-plugins — one DeepSeek Harness bundle carrying nine independently switchable plugins (colgrep, codegraph, project-mcp, git-bash, superpowers, ponytail, init, fix, lan-access) plus a management tab in the Plugins page.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -80,7 +80,8 @@
|
|
|
80
80
|
"platform": "web",
|
|
81
81
|
"inject": [
|
|
82
82
|
"@deepseek-ai/dsh-api-remotes",
|
|
83
|
-
"@deepseek-ai/dsh-client-modules"
|
|
83
|
+
"@deepseek-ai/dsh-client-modules",
|
|
84
|
+
"@deepseek-ai/dsh-client-ui-commands"
|
|
84
85
|
]
|
|
85
86
|
}
|
|
86
87
|
},
|