@shithubpro/dsh 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +72 -2
- package/cordis.patch.yml +3 -0
- package/lib/client.js +172 -0
- package/lib/index.js +15122 -0
- package/package.json +33 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ShitHub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ShitHub for DeepSeek Harness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DSH 原生插件:侧栏增加 **ShitHub**,点击后在主区域打开完整广场,点「返回对话」回到当前会话。适配 DSH **0.2.1-rc.4**。
|
|
4
|
+
|
|
5
|
+
连接 **ShitHub 线上后端**。从 0.2.0 起,壳子独立启动 npm 上的 `@shithubpro/mcp`,不再把 MCP 业务代码和 iframe 打进壳子。DSH 里可以直接安装 `@shithubpro/dsh`。
|
|
6
|
+
|
|
7
|
+
## 构建与安装
|
|
8
|
+
|
|
9
|
+
在项目根目录执行(构建工具与 MCP SDK 依赖取自 `mcp/node_modules`):
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm --prefix mcp ci
|
|
13
|
+
npm --prefix dsh run build
|
|
14
|
+
npm --prefix dsh test
|
|
15
|
+
npm --prefix dsh run pack:local
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
DSH → 插件 → 添加,输入压缩包的**绝对路径**,安装后启用:
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
/Users/wzz/learn/shithub/dsh/artifacts/shithubpro-dsh-0.2.1.tgz
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
已有 0.1.x 的用户需要安装这一次新版壳子。也可以安装构建好的本地 `dsh/` 目录,或直接输入 `@shithubpro/dsh`。
|
|
25
|
+
|
|
26
|
+
## 启动与更新
|
|
27
|
+
|
|
28
|
+
- **首次打开**:本机没有独立 MCP 时,下载 npm `latest` 指向的稳定版本及其依赖,再启动。安装使用 DSH profile 提供的 pnpm,不要求另外安装 npm。
|
|
29
|
+
- **后续打开**:直接启动已安装版本,不等待版本查询或下载。切回广场复用该插件实例已有的 MCP 进程。
|
|
30
|
+
- **后台更新**:MCP 启动后尝试检查更新,距离上次成功查询不足 6 小时则复用记录;持续运行期间每 6 小时再检查。依赖装到独立临时目录,安装校验完成后才成为可启动版本。
|
|
31
|
+
- **下次启动切换**:运行中的 MCP 和 iframe 始终使用原版本。重启 DSH,或禁用后重新启用本插件、再打开广场,才会选择已下载的新版本。只关闭再打开广场不会切换。
|
|
32
|
+
- **失败处理**:后台查询失败不影响当前使用,距离上次成功检查不足 6 小时则不再查询。下载或校验失败不记成成功检查,下次打开会重新下载。新版本本次启动失败时继续用已安装的旧版,不隔离该版本,下次启动再试新版本。首次下载失败可点击页面「重试」。
|
|
33
|
+
- **无需重打壳子**:日常 MCP 业务与 iframe 更新只需发布 `@shithubpro/mcp` 并更新 npm 的 `latest`。修改宿主桥接或启动器时仍需发布 DSH 壳子。本地尚未发布的 MCP/UI 修改不会随本壳子分发。
|
|
34
|
+
|
|
35
|
+
版本文件默认位于 `~/.shithub/dsh/runtime/<平台>-<架构>-node<主版本>/`,也可用 `SHITHUB_DSH_RUNTIME_DIR` 指定缓存根目录。各版本独立保存,已有进程使用的文件不会被覆盖;失败下载的临时目录会清理。目录中的 `update.log` 记录本地启动版本、下载结果和回退原因。缓存只保存代码,身份数据沿用原目录。
|
|
36
|
+
|
|
37
|
+
## 适配范围
|
|
38
|
+
|
|
39
|
+
- 通过标准 MCP stdio 协议连接独立服务,声明 MCP Apps UI 能力,保留工具结果的 `_meta`、`isError` 和现有确认流程。iframe URI 从实际运行版本的 `shithub_browse` 工具元数据读取。
|
|
40
|
+
- 使用 DSH 已挂载的 Connection 鉴权入口,精确注册 `/api/shithub/document`、`/api/shithub/callTool`,仅所有者可访问。
|
|
41
|
+
- 这是独立社区面板,不向 DSH 模型注册工具;在广场内操作不调用模型。需要 Agent 操作时可另配 MCP 服务。
|
|
42
|
+
- iframe 隔离、主题同步和返回对话行为沿用 0.1.1。禁用插件会取消下载及待完成的登录,并关闭 MCP 子进程。
|
|
43
|
+
- 默认身份数据仍为 `~/.shithub/dsh/production/`,与 Codex MCP 独立。显式设置 `SHITHUB_DATA_DIR` 时沿用 `<目录>/production/` 规则。
|
|
44
|
+
- 本次仅修改 `dsh/`,不修改 Codex / VS Code 插件配置。
|
|
45
|
+
|
|
46
|
+
## 验证
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npm --prefix dsh run build
|
|
50
|
+
npm --prefix dsh test
|
|
51
|
+
DSH_NODE_MODULES=/path/to/extracted/dsh/node_modules npm --prefix dsh run test:dsh
|
|
52
|
+
DSH_NODE_COMMAND=/path/to/dsh/node DSH_PNPM_ENTRY=/path/to/dsh/pnpm.mjs npm --prefix dsh run test:install
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
测试覆盖独立 MCP stdio 连接与动态 UI URI、缓存启动不等待下载、完整安装后下次切换、下载取消、并发安装、坏版本回退、定期更新、插件禁用清理,以及 iframe 来源校验、握手和主题同步。真实 MCP 入口测试拦截全部 fetch 并使用临时身份目录,不访问线上数据。
|
|
56
|
+
|
|
57
|
+
`test:dsh` 使用实际 DSH Cordis 与 HostConnectionService,覆盖原 HTTP 405 故障、鉴权、路由卸载和构建产物启动缓存 MCP。`test:install` 使用 DSH 自带 pnpm,离线安装测试压缩包并验证版本目录移动后仍能启动。
|
|
58
|
+
|
|
59
|
+
这些自动化检查不等同于桌面实测,也不覆盖 npm 公网下载的实际连通性。桌面验收:安装 → 首次打开广场完成下载 → 返回再打开 → 主题切换 → 禁用并重新启用。登录、发帖、评论和删除由测试用户在界面明确操作。
|
|
60
|
+
|
|
61
|
+
## 版本记录
|
|
62
|
+
|
|
63
|
+
### 0.2.1
|
|
64
|
+
|
|
65
|
+
等待广场打开时说明正在启动,并提示第一次打开需要安装、可能要几分钟。
|
|
66
|
+
|
|
67
|
+
### 0.2.0
|
|
68
|
+
|
|
69
|
+
拆分本地启动器与独立 MCP,支持缓存启动、后台更新、下次启动切换和启动失败回退。通过 DSH 自带 pnpm 安装,保留原身份目录和 iframe 交互;Codex 更新机制保持现状。
|
|
70
|
+
|
|
71
|
+
### 0.1.1
|
|
72
|
+
|
|
73
|
+
修复 `transport failure for /shithub/document: HTTP 405`:改用 Connection 的精确 Fetch 路由,沿用 DSH 已挂载的鉴权入口。0.1.0 的自定义 RPC 注册在 DSH 0.2.1-rc.4 中触发 `cannot get property "webServer" without inject`;仅补 `webServer` 依赖仍会失败。
|
package/cordis.patch.yml
ADDED
package/lib/client.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "@shithubpro/dsh", factory: (require) => {
|
|
2
|
+
const module = { exports: {} }; const exports = module.exports;
|
|
3
|
+
"use strict";
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
|
|
32
|
+
// src/client.jsx
|
|
33
|
+
var client_exports = {};
|
|
34
|
+
__export(client_exports, {
|
|
35
|
+
apply: () => apply,
|
|
36
|
+
inject: () => inject
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(client_exports);
|
|
39
|
+
var import_react = __toESM(require("react"), 1);
|
|
40
|
+
|
|
41
|
+
// src/bridge.js
|
|
42
|
+
var CHANNEL = "/api";
|
|
43
|
+
async function callHost(connection, method, payload, signal) {
|
|
44
|
+
const result = await connection.rpc.call(CHANNEL, `shithub/${method}`, payload, signal);
|
|
45
|
+
if (!result.ok) throw new Error(result.error?.message || "ShitHub \u8BF7\u6C42\u5931\u8D25");
|
|
46
|
+
return result.value;
|
|
47
|
+
}
|
|
48
|
+
function attachBridge({ target, frame, connection, hostContext, onError }) {
|
|
49
|
+
const lifetime = new AbortController();
|
|
50
|
+
let opened = false;
|
|
51
|
+
const send = (message) => {
|
|
52
|
+
if (!lifetime.signal.aborted) frame()?.postMessage({ jsonrpc: "2.0", ...message }, "*");
|
|
53
|
+
};
|
|
54
|
+
const listener = async (event) => {
|
|
55
|
+
if (!frame() || event.source !== frame()) return;
|
|
56
|
+
const message = event.data;
|
|
57
|
+
if (!message || message.jsonrpc !== "2.0" || typeof message.method !== "string") return;
|
|
58
|
+
const hasId = Object.hasOwn(message, "id");
|
|
59
|
+
try {
|
|
60
|
+
if (message.method === "ui/notifications/initialized" && !opened) {
|
|
61
|
+
opened = true;
|
|
62
|
+
const result2 = await callHost(connection, "callTool", { name: "shithub_browse", arguments: {} }, lifetime.signal);
|
|
63
|
+
send({ method: "ui/notifications/tool-result", params: result2 });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!hasId) return;
|
|
67
|
+
let result;
|
|
68
|
+
if (message.method === "ui/initialize") {
|
|
69
|
+
result = {
|
|
70
|
+
protocolVersion: "2025-06-18",
|
|
71
|
+
hostInfo: { name: "DeepSeek Harness / ShitHub", version: "0.2.1" },
|
|
72
|
+
hostCapabilities: { serverTools: {} },
|
|
73
|
+
hostContext: hostContext()
|
|
74
|
+
};
|
|
75
|
+
} else if (message.method === "tools/call") {
|
|
76
|
+
result = await callHost(connection, "callTool", message.params, lifetime.signal);
|
|
77
|
+
} else if (message.method === "ping") {
|
|
78
|
+
result = {};
|
|
79
|
+
} else {
|
|
80
|
+
send({ id: message.id, error: { code: -32601, message: "\u4E0D\u652F\u6301\u7684\u754C\u9762\u8BF7\u6C42" } });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
send({ id: message.id, result });
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (lifetime.signal.aborted) return;
|
|
86
|
+
const text = error instanceof Error ? error.message : "ShitHub \u8BF7\u6C42\u5931\u8D25";
|
|
87
|
+
if (hasId) send({ id: message.id, error: { code: -32603, message: text } });
|
|
88
|
+
else onError(text);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
target.addEventListener("message", listener);
|
|
92
|
+
return {
|
|
93
|
+
updateContext() {
|
|
94
|
+
send({ method: "ui/notifications/host-context-changed", params: hostContext() });
|
|
95
|
+
},
|
|
96
|
+
dispose() {
|
|
97
|
+
lifetime.abort();
|
|
98
|
+
target.removeEventListener("message", listener);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/client.jsx
|
|
104
|
+
var inject = ["slots", "layout", "connection", "theme"];
|
|
105
|
+
var PANEL_ID = "shithub";
|
|
106
|
+
function ShitHubIcon({ size = 18 }) {
|
|
107
|
+
return /* @__PURE__ */ import_react.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", "aria-hidden": "true" }, /* @__PURE__ */ import_react.default.createElement("circle", { cx: "12", cy: "12", r: "12", fill: "#1e1e1e" }), /* @__PURE__ */ import_react.default.createElement("path", { fill: "#fff", transform: "translate(12 12) scale(0.76) translate(-12 -12)", d: "M19.58 14.17c.27-.5.42-1.06.42-1.67c0-1.64-1.14-3.02-2.67-3.4c.07-.5.02-.97-.14-1.42c-.49-1.33-1.9-2.06-3.21-2.61c-1.69-.7-1.78-1.95-1.78-2.08c0-.34-.18-.66-.47-.85s-.66-.2-.97-.05c-.15.07-3.77 1.85-4.47 4.72a4.1 4.1 0 0 0 .12 2.35a3.506 3.506 0 0 0-2 5a3.505 3.505 0 0 0-2.42 3.33c0 1.93 1.57 3.5 3.5 3.5h13c1.93 0 3.5-1.57 3.5-3.5c0-1.55-1.02-2.88-2.42-3.33ZM18.5 19h-13c-.83 0-1.5-.67-1.5-1.5S4.67 16 5.5 16h2c.55 0 1-.45 1-1s-.45-1-1-1c-.83 0-1.5-.67-1.5-1.5S6.67 11 7.5 11H8c.38 0 .73-.21.89-.55s.13-.74-.09-1.05c-.54-.72-.73-1.41-.56-2.11c.27-1.12 1.4-2.12 2.34-2.77c.38.81 1.13 1.77 2.63 2.4c1.24.52 1.93 1 2.1 1.46c.04.11.16.43-.21 1.17c-.15.31-.14.68.04.97s.5.47.85.47h.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5c-.55 0-1 .45-1 1s.45 1 1 1h2c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5Z" }));
|
|
108
|
+
}
|
|
109
|
+
function CommunityPanel({ connection, theme, onThemeChange, back }) {
|
|
110
|
+
const frame = (0, import_react.useRef)(null);
|
|
111
|
+
const [html, setHtml] = (0, import_react.useState)("");
|
|
112
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
113
|
+
const [attempt, setAttempt] = (0, import_react.useState)(0);
|
|
114
|
+
(0, import_react.useEffect)(() => {
|
|
115
|
+
const lifetime = new AbortController();
|
|
116
|
+
setHtml("");
|
|
117
|
+
setError("");
|
|
118
|
+
const bridge = attachBridge({
|
|
119
|
+
target: window,
|
|
120
|
+
frame: () => frame.current?.contentWindow,
|
|
121
|
+
connection,
|
|
122
|
+
hostContext: () => ({ theme: theme.getTheme().active.colorScheme, displayMode: "fullscreen" }),
|
|
123
|
+
onError: setError
|
|
124
|
+
});
|
|
125
|
+
const unsubscribe = onThemeChange(() => bridge.updateContext());
|
|
126
|
+
void callHost(connection, "document", {}, lifetime.signal).then(({ html: html2 }) => {
|
|
127
|
+
if (!lifetime.signal.aborted) setHtml(html2);
|
|
128
|
+
}).catch((error2) => {
|
|
129
|
+
if (!lifetime.signal.aborted) setError(error2.message);
|
|
130
|
+
});
|
|
131
|
+
return () => {
|
|
132
|
+
lifetime.abort();
|
|
133
|
+
bridge.dispose();
|
|
134
|
+
unsubscribe();
|
|
135
|
+
};
|
|
136
|
+
}, [connection, theme, onThemeChange, attempt]);
|
|
137
|
+
const buttonStyle = { cursor: "pointer", color: "inherit", background: "transparent", border: "1px solid currentColor", borderRadius: 6, padding: "4px 10px", font: "inherit" };
|
|
138
|
+
return /* @__PURE__ */ import_react.default.createElement("section", { style: { display: "flex", flexDirection: "column", height: "100%", flex: 1, minHeight: 0, minWidth: 0 }, "aria-label": "ShitHub \u5E7F\u573A" }, /* @__PURE__ */ import_react.default.createElement("header", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12, padding: "10px 16px", flexShrink: 0 } }, /* @__PURE__ */ import_react.default.createElement("strong", null, "ShitHub Pro"), /* @__PURE__ */ import_react.default.createElement("button", { type: "button", style: buttonStyle, onClick: back }, "\u8FD4\u56DE\u5BF9\u8BDD")), error && /* @__PURE__ */ import_react.default.createElement("div", { role: "alert", style: { padding: 16 } }, /* @__PURE__ */ import_react.default.createElement("p", null, "\u5E7F\u573A\u52A0\u8F7D\u5931\u8D25\uFF1A", error), /* @__PURE__ */ import_react.default.createElement("button", { type: "button", style: buttonStyle, onClick: () => setAttempt((value) => value + 1) }, "\u91CD\u8BD5")), !html && !error && /* @__PURE__ */ import_react.default.createElement("p", { role: "status", style: { padding: 16 } }, "\u6B63\u5728\u542F\u52A8 ShitHub Pro\uFF0C\u8BF7\u7A0D\u7B49\u3002\u7B2C\u4E00\u6B21\u6253\u5F00\u9700\u8981\u5B89\u88C5\uFF0C\u53EF\u80FD\u8981\u51E0\u5206\u949F\u3002"), html && /* @__PURE__ */ import_react.default.createElement(
|
|
139
|
+
"iframe",
|
|
140
|
+
{
|
|
141
|
+
ref: frame,
|
|
142
|
+
key: attempt,
|
|
143
|
+
title: "ShitHub \u793E\u533A",
|
|
144
|
+
srcDoc: html,
|
|
145
|
+
sandbox: "allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads",
|
|
146
|
+
allow: "clipboard-write",
|
|
147
|
+
referrerPolicy: "no-referrer",
|
|
148
|
+
style: { display: "block", width: "100%", flex: 1, minHeight: 0, border: 0 }
|
|
149
|
+
}
|
|
150
|
+
));
|
|
151
|
+
}
|
|
152
|
+
function apply(ctx) {
|
|
153
|
+
const face = {
|
|
154
|
+
connection: ctx.connection,
|
|
155
|
+
theme: ctx.theme,
|
|
156
|
+
onThemeChange: (handler) => ctx.on("theme/change", handler),
|
|
157
|
+
back: () => ctx.layout.selectPanel(null)
|
|
158
|
+
};
|
|
159
|
+
ctx.slots.inject("main", () => ctx.slots.register({
|
|
160
|
+
name: "main",
|
|
161
|
+
key: PANEL_ID,
|
|
162
|
+
inject: () => face
|
|
163
|
+
}, CommunityPanel));
|
|
164
|
+
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
165
|
+
name: "sidebar.panellist",
|
|
166
|
+
id: PANEL_ID,
|
|
167
|
+
order: 20,
|
|
168
|
+
label: "ShitHub Pro"
|
|
169
|
+
}, ShitHubIcon));
|
|
170
|
+
}
|
|
171
|
+
return module.exports;
|
|
172
|
+
} });
|