dsh-remote-plugin 0.8.0-rc.4 → 0.8.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +10 -5
- package/README.md +10 -5
- package/apk/dsh-remote.apk +0 -0
- package/client.js +21 -4
- package/doctor-skill.mjs +99 -0
- package/doctor-target.mjs +24 -0
- package/gateway.cjs +629 -147
- package/index.mjs +87 -22
- package/insights.mjs +11 -6
- package/market.mjs +83 -0
- package/package.json +6 -1
- package/peak-reminders.mjs +7 -4
- package/plugin-center.mjs +163 -33
- package/plugin-transaction.mjs +277 -0
- package/public/activity.js +58 -1
- package/public/admin.html +51 -16
- package/public/admin.js +159 -117
- package/public/app.js +478 -161
- package/public/approval-records.js +229 -0
- package/public/build.json +2 -2
- package/public/desktop/desktop.css +52 -0
- package/public/desktop/desktop.html +63 -9
- package/public/desktop/desktop.js +382 -110
- package/public/doctor-entry.js +94 -0
- package/public/doctor.css +205 -0
- package/public/doctor.js +769 -0
- package/public/extensions.js +5 -5
- package/public/history.js +6 -1
- package/public/image-preview.js +22 -6
- package/public/index.html +68 -15
- package/public/insights.css +7 -0
- package/public/insights.js +11 -5
- package/public/md.js +91 -34
- package/public/network.js +15 -1
- package/public/onboarding.css +36 -0
- package/public/onboarding.js +253 -0
- package/public/operations.js +1 -1
- package/public/permission-presets.js +159 -0
- package/public/plugin-center.css +12 -0
- package/public/plugin-center.js +161 -26
- package/public/plugin.html +36 -130
- package/public/plugin.js +66 -66
- package/public/remote-state.js +27 -0
- package/public/remote-ui.css +148 -0
- package/public/remote-ui.js +243 -0
- package/public/session-presets.js +47 -0
- package/public/setup.css +18 -0
- package/public/setup.js +213 -0
- package/public/skins/blue-fish/face.png +0 -0
- package/public/skins/blue-fish/icon-blush.png +0 -0
- package/public/skins/blue-fish/icon-sleep.png +0 -0
- package/public/skins/blue-fish/icon-smile.png +0 -0
- package/public/skins/blue-fish/icon-star.png +0 -0
- package/public/skins/blue-fish/icon-wink.png +0 -0
- package/public/skins/blue-fish/icon.png +0 -0
- package/public/skins/blue-fish/mascot.png +0 -0
- package/public/skins/blue-fish/pattern.png +0 -0
- package/public/skins/blue-fish/preview.html +289 -0
- package/public/skins/blue-fish/skin.css +573 -0
- package/public/styles.css +48 -2
- package/public/theme-vars.css +79 -4
- package/public/theme.js +7 -13
- package/public/turn-results.js +3 -1
- package/public/update.json +4 -4
- package/public/version.json +1 -1
- package/public/workflow.css +3 -0
- package/public/workflow.js +14 -4
- package/skills/dsh-remote-doctor/SKILL.md +170 -0
package/README.en.md
CHANGED
|
@@ -13,7 +13,7 @@ dsh plugin --profile web list --depth 0
|
|
|
13
13
|
|
|
14
14
|
Use the actual profile for custom setups. DSH Desktop uses its own plugin manager and needs a complete exit/reopen. For Web, fully restart DSH Web, hard-refresh with Ctrl+F5 and open Remote in the sidebar.
|
|
15
15
|
|
|
16
|
-
On the host, open `http://127.0.0.1:8787/health`, then
|
|
16
|
+
On the host, open `http://127.0.0.1:8787/health`, then display a connection QR in the plugin wizard or admin console. Scan it at More → Hosts and connections → Scan to connect; the APK download QR only installs the app. A phone connects to `http://PC-LAN-IP:8787` with its token, not its own localhost. Pin a published version with `@<version>`; check the actual `@next` and `@latest` tags separately.
|
|
17
17
|
|
|
18
18
|
## Capabilities and limits
|
|
19
19
|
|
|
@@ -22,11 +22,14 @@ On the host, open `http://127.0.0.1:8787/health`, then pair through the admin QR
|
|
|
22
22
|
- mux/host downlinks, independent long polling, weak-network settings and local history.
|
|
23
23
|
- Allowed file roots, resumable chunks, hashes, previews/downloads and image attachments.
|
|
24
24
|
- Current-host plugin management and optional context/cost insights.
|
|
25
|
-
- Mobile navigation: Sessions, Files,
|
|
25
|
+
- Mobile navigation: Sessions, Files, More; six Web themes, defaulting to Blue Fat Fish while preserving existing choices.
|
|
26
|
+
- Eight-step mobile guide; finishing or skipping the entire guide removes its home invitation. Replay at More → Preferences and maintenance → Getting started.
|
|
27
|
+
- rc.9 includes cold-session recovery and error-attribution fixes, send-result diagnostics, and upload/branch recovery validation; see the candidate notes for scope.
|
|
26
28
|
- Existing Android APKs are bundled when available; notifications/background require device permissions.
|
|
27
|
-
- Windows Desktop lifecycle control is experimental
|
|
29
|
+
- Windows Desktop lifecycle control is experimental and needs verified instance evidence. Optional gateway login startup is available in admin, off by default; no system service is installed.
|
|
28
30
|
- HarmonyOS is a separate source project; release CI does not build HAPs. Insights and Web GenUI are not ported.
|
|
29
|
-
- Android ASR
|
|
31
|
+
- The Android ASR bridge and empty feature-test entry were removed; notification tests are in advanced notification options.
|
|
32
|
+
- macOS can run the plugin's gateway source. Main release CI is configured for an Apple Silicon standalone gateway, ad-hoc signing and startup smoke checks; it does not notarize with Apple.
|
|
30
33
|
|
|
31
34
|
## Configuration and troubleshooting
|
|
32
35
|
|
|
@@ -42,12 +45,14 @@ Keep QR codes and credentials private. Prefer Tailscale across networks. Remote
|
|
|
42
45
|
|
|
43
46
|
- [Documentation index](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/README.md)
|
|
44
47
|
- [Installation](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/getting-started.md)
|
|
48
|
+
- [rc.9 changes and validation scope](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/rc-0.8.0-rc.9.md)
|
|
49
|
+
- [Getting started guide](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/onboarding-guided-practice.md)
|
|
45
50
|
- [Configuration](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/configuration.md)
|
|
46
51
|
- [Troubleshooting](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/troubleshooting.md)
|
|
47
52
|
- [Main project](https://github.com/Blank-not-black/dsh-Remote)
|
|
48
53
|
- [Releases](https://github.com/Blank-not-black/dsh-Remote/releases)
|
|
49
54
|
|
|
50
|
-
Checked against repository 0.
|
|
55
|
+
Checked against repository 0.8.0-rc.9 on 2026-10-22. This does not verify current npm tags, installed devices, public assets or all platform behavior. Detailed guides are currently in Chinese.
|
|
51
56
|
|
|
52
57
|
## License
|
|
53
58
|
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ dsh plugin --profile web list --depth 0
|
|
|
13
13
|
|
|
14
14
|
示例针对 Web profile;自定义 profile 使用实际名称。DSH Desktop 从自身插件管理入口安装,完整退出并重开。Web 安装完成后完整重启 DSH Web,Ctrl+F5,从侧栏打开 Remote。
|
|
15
15
|
|
|
16
|
-
在主机访问 `http://127.0.0.1:8787/health
|
|
16
|
+
在主机访问 `http://127.0.0.1:8787/health`,然后在插件连接向导或管理控制台显示连接二维码。手机通过「更多 → 主机与连接 → 扫码连接」配对;APK 下载码只用于安装。手动连接填 `http://电脑局域网IP:8787` 与令牌,不能填手机 localhost。固定版本使用 `@<已发布版本>`,`@next` 与 `@latest` 的指向需另行查询。
|
|
17
17
|
|
|
18
18
|
## 当前能力与限制
|
|
19
19
|
|
|
@@ -22,11 +22,14 @@ dsh plugin --profile web list --depth 0
|
|
|
22
22
|
- mux/host 下行、独立长轮询、弱网设置与历史缓存。
|
|
23
23
|
- 文件多根、分块续传、校验、预览/下载与图片附件。
|
|
24
24
|
- 当前主机插件管理与可选上下文/费用洞察。
|
|
25
|
-
-
|
|
25
|
+
- 手机导航:会话、文件、更多;六套 Web 主题,默认蓝色大肥鱼,保留已有主题选择。
|
|
26
|
+
- 手机端八步新手引导;完成或整体跳过后移除首页入口,在「更多 → 偏好与维护 → 新手引导」重新学习。
|
|
27
|
+
- rc.9 补充冷会话恢复与错误归属修复、发送结果诊断、文件上传与分支恢复验证;具体范围见候选版说明。
|
|
26
28
|
- Android APK 在已有构建产物时随包分发,通知与后台需设备权限。
|
|
27
|
-
- Windows Desktop
|
|
29
|
+
- Windows Desktop 控制是实验能力,需可信实例证据;管理页可选网关登录自启,默认关闭,不注册系统服务。
|
|
28
30
|
- HarmonyOS 为独立源码工程,当前 release CI 不构建 HAP;会话洞察和 Web GenUI 未移植。
|
|
29
|
-
- Android ASR
|
|
31
|
+
- Android ASR 桥和空功能测试页入口已移除;通知测试位于高级通知选项。
|
|
32
|
+
- macOS 可通过插件使用同一网关源码;主发布 CI 已配置 Apple Silicon 独立网关构建、ad-hoc 签名和启动冒烟,未做 Apple 公证。
|
|
30
33
|
|
|
31
34
|
## 配置与排查
|
|
32
35
|
|
|
@@ -42,12 +45,14 @@ dsh plugin --profile web list --depth 0
|
|
|
42
45
|
|
|
43
46
|
- [完整文档](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/README.md)
|
|
44
47
|
- [安装与连接](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/getting-started.md)
|
|
48
|
+
- [rc.9 变化与验证范围](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/rc-0.8.0-rc.9.md)
|
|
49
|
+
- [新手引导](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/onboarding-guided-practice.md)
|
|
45
50
|
- [配置](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/configuration.md)
|
|
46
51
|
- [故障排查](https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/troubleshooting.md)
|
|
47
52
|
- [主项目与下载](https://github.com/Blank-not-black/dsh-Remote)
|
|
48
53
|
- [GitHub Releases](https://github.com/Blank-not-black/dsh-Remote/releases)
|
|
49
54
|
|
|
50
|
-
说明按仓库 0.
|
|
55
|
+
说明按仓库 0.8.0-rc.9(2026-10-22)核对,不代表当前 npm 标签、设备实装、公开附件或所有平台验收结果。
|
|
51
56
|
|
|
52
57
|
## License
|
|
53
58
|
|
package/apk/dsh-remote.apk
CHANGED
|
Binary file
|
package/client.js
CHANGED
|
@@ -25,9 +25,9 @@ window.__ModuleLoader__.load({
|
|
|
25
25
|
// keep a safe fallback for Desktop hosts without that value.
|
|
26
26
|
position: 'fixed', top: window.location && window.location.protocol === 'dsh-app:' ? 'calc(12px + env(titlebar-area-height, 40px))' : 12,
|
|
27
27
|
right: 12, bottom: 12, zIndex: 2147483000,
|
|
28
|
-
width: 'min(520px, calc(100vw - 24px))', background: '
|
|
29
|
-
border: '1px solid rgba(
|
|
30
|
-
boxShadow: '-16px
|
|
28
|
+
width: 'min(520px, calc(100vw - 24px))', background: 'transparent',
|
|
29
|
+
border: '1px solid rgba(128,128,128,.25)', borderRadius: 16, overflow: 'hidden',
|
|
30
|
+
boxShadow: '-12px 16px 42px rgba(0,0,0,.24)',
|
|
31
31
|
transform: 'translateX(102%)', transition: 'transform .22s ease',
|
|
32
32
|
display: 'flex', flexDirection: 'column',
|
|
33
33
|
}
|
|
@@ -35,12 +35,14 @@ window.__ModuleLoader__.load({
|
|
|
35
35
|
// 动态注入列布局, 让各 footer action 上下堆叠。
|
|
36
36
|
var FOOTER_FIX_ID = 'dsh-remote-footer-stack'
|
|
37
37
|
var FOOTER_FIX_CSS = '.kIs9zW_footerActions{flex-direction:column!important;align-items:stretch!important}'
|
|
38
|
-
var PLUGIN_THEMES = ['default', 'dark', 'light', 'neutral']
|
|
38
|
+
var PLUGIN_THEMES = ['default', 'dark', 'light', 'neutral', 'mono', 'fish']
|
|
39
39
|
var ICON_PALETTES = {
|
|
40
40
|
default: { bg: '#F6F9FF', upper: '#4F7FEF', lower: '#8A64D8' },
|
|
41
41
|
dark: { bg: '#FFF4E3', upper: '#C66A00', lower: '#8A5A24' },
|
|
42
42
|
light: { bg: '#FFF9EF', upper: '#9B6A20', lower: '#66517F' },
|
|
43
43
|
neutral: { bg: '#F4F0DF', upper: '#585818', lower: '#832D15' },
|
|
44
|
+
mono: { bg: '#F5F5F5', upper: '#222222', lower: '#555555' },
|
|
45
|
+
fish: { bg: '#EAF6FF', upper: '#2F52D0', lower: '#537CC4' },
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
function currentPluginTheme() {
|
|
@@ -132,12 +134,18 @@ window.__ModuleLoader__.load({
|
|
|
132
134
|
function Drawer(props) {
|
|
133
135
|
var open = props.useStore(function (s) { return s.open })
|
|
134
136
|
var loaded = React.useRef(false)
|
|
137
|
+
var frame = React.useRef(null)
|
|
135
138
|
if (open) loaded.current = true
|
|
136
139
|
// 管理页里的「收起面板」通过 postMessage 请求父窗口关闭抽屉
|
|
137
140
|
React.useEffect(function () {
|
|
138
141
|
function onMsg(e) {
|
|
139
142
|
if (e.origin !== location.origin) return
|
|
140
143
|
var d = e.data
|
|
144
|
+
if (d && d.source === 'dsh-remote-admin' && d.type === 'open-session' && e.source === frame.current?.contentWindow && typeof d.sessionId === 'string' && /^[a-zA-Z0-9_-]{1,200}$/.test(d.sessionId) && typeof d.requestId === 'string') {
|
|
145
|
+
var opened = props.openSession(d.sessionId)
|
|
146
|
+
e.source.postMessage({source:'dsh-remote-host',requestId:d.requestId,opened:opened},e.origin)
|
|
147
|
+
if(opened) props.actions.close()
|
|
148
|
+
}
|
|
141
149
|
if (d && (d.source === 'dsh-remote-admin' || d.source === 'dsh-remote-plugin') && d.type === 'close') props.actions.close()
|
|
142
150
|
}
|
|
143
151
|
window.addEventListener('message', onMsg)
|
|
@@ -154,6 +162,7 @@ window.__ModuleLoader__.load({
|
|
|
154
162
|
}),
|
|
155
163
|
},
|
|
156
164
|
loaded.current ? React.createElement('iframe', {
|
|
165
|
+
ref: frame,
|
|
157
166
|
src: '/remote/plugin.html',
|
|
158
167
|
title: 'DSH Remote 快速状态面板',
|
|
159
168
|
sandbox: 'allow-scripts allow-same-origin allow-forms allow-modals allow-popups',
|
|
@@ -163,6 +172,13 @@ window.__ModuleLoader__.load({
|
|
|
163
172
|
|
|
164
173
|
var inject = ['slots']
|
|
165
174
|
function apply(ctx) {
|
|
175
|
+
var navigation = null
|
|
176
|
+
// Declare optional service access, including hosts that start navigation
|
|
177
|
+
// after plugins. The panel remains usable without native navigation.
|
|
178
|
+
if (typeof ctx.inject === 'function') ctx.inject(['uiWorkspace'], function (child) {
|
|
179
|
+
navigation = child.get('uiWorkspace')
|
|
180
|
+
child.effect(function () { return function () { navigation = null } }, 'dsh-remote: native diagnosis navigation')
|
|
181
|
+
})
|
|
166
182
|
var store = storeRuntime.defineStore({
|
|
167
183
|
init: function () { return { open: false } },
|
|
168
184
|
actions: {
|
|
@@ -187,6 +203,7 @@ window.__ModuleLoader__.load({
|
|
|
187
203
|
name: 'shell.overlay',
|
|
188
204
|
id: 'dsh-remote-drawer',
|
|
189
205
|
store,
|
|
206
|
+
inject: function () { return {openSession:function(id){try{if(typeof navigation?.openSession!=='function')return false;navigation.openSession(id);return true}catch(_){return false}}} },
|
|
190
207
|
}, Drawer)
|
|
191
208
|
})
|
|
192
209
|
}, 'dsh-remote: overlay drawer')
|
package/doctor-skill.mjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Bundled read-only diagnosis skill for DSH Remote.
|
|
2
|
+
// Registration is best-effort: an older DSH without the skill registry must
|
|
3
|
+
// still load the Remote plugin, and the client keeps a prompt-only fallback.
|
|
4
|
+
import { readFileSync } from 'node:fs'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
|
|
8
|
+
export const DOCTOR_SKILL_NAME = 'dsh-remote-doctor'
|
|
9
|
+
const SKILL_DIR = fileURLToPath(new URL('./skills/dsh-remote-doctor/', import.meta.url))
|
|
10
|
+
const SKILL_PATH = join(SKILL_DIR, 'SKILL.md')
|
|
11
|
+
const DESCRIPTION = 'Diagnose DSH Remote plugin and client problems with read-only evidence. Use when the user reports a DSH Remote connection, gateway, plugin update, mobile/desktop UI, notification, file-transfer, or model/session problem and asks for a cause analysis, troubleshooting steps, or an issue-ready feedback draft.'
|
|
12
|
+
const WHEN_TO_USE = 'The user is troubleshooting DSH Remote itself, wants evidence collected on their own machine, or asks whether a problem is a plugin defect.'
|
|
13
|
+
const PROVIDER = 'dsh-remote-doctor'
|
|
14
|
+
const BUNDLED_SKILL_RANK = 600
|
|
15
|
+
|
|
16
|
+
let body
|
|
17
|
+
const registrations = new WeakMap()
|
|
18
|
+
export const doctorSkillStatus = ctx => registrations.get(ctx) || 'unconfirmed'
|
|
19
|
+
|
|
20
|
+
function skillBody() {
|
|
21
|
+
if (body !== undefined) return body
|
|
22
|
+
const raw = readFileSync(SKILL_PATH, 'utf8').replace(/^\uFEFF/, '')
|
|
23
|
+
body = raw.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, '').trim()
|
|
24
|
+
if (!body) throw new Error('dsh-remote-doctor skill body is empty')
|
|
25
|
+
return body
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register the packaged doctor skill with the optional DSH skill registry.
|
|
30
|
+
* Returns false instead of failing plugin startup when this DSH build has no
|
|
31
|
+
* skill service or the packaged asset is unavailable.
|
|
32
|
+
*/
|
|
33
|
+
function registerProvider(ctx) {
|
|
34
|
+
let skills
|
|
35
|
+
try {
|
|
36
|
+
// Cordis may reject access to an optional service before a method can be
|
|
37
|
+
// tested. A missing/undeclared skill registry must not abort Remote.apply.
|
|
38
|
+
skills = ctx?.get?.('skills') ?? ctx?.skills
|
|
39
|
+
if (typeof skills?.registerProvider !== 'function' || typeof ctx?.effect !== 'function') return false
|
|
40
|
+
} catch { return false }
|
|
41
|
+
let content
|
|
42
|
+
try {
|
|
43
|
+
content = skillBody()
|
|
44
|
+
} catch (error) {
|
|
45
|
+
try { ctx.logger?.warn?.('dsh-remote: doctor skill unavailable: ' + (error?.message || String(error))) } catch {}
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
const candidate = {
|
|
49
|
+
name: DOCTOR_SKILL_NAME,
|
|
50
|
+
description: DESCRIPTION,
|
|
51
|
+
whenToUse: WHEN_TO_USE,
|
|
52
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
53
|
+
provider: PROVIDER,
|
|
54
|
+
source: 'bundled',
|
|
55
|
+
path: SKILL_PATH,
|
|
56
|
+
resourceBase: { kind: 'directory', path: SKILL_DIR },
|
|
57
|
+
rank: BUNDLED_SKILL_RANK,
|
|
58
|
+
locator: SKILL_PATH,
|
|
59
|
+
}
|
|
60
|
+
const provider = {
|
|
61
|
+
name: PROVIDER,
|
|
62
|
+
list: () => Promise.resolve([candidate]),
|
|
63
|
+
get: () => Promise.resolve({
|
|
64
|
+
name: DOCTOR_SKILL_NAME,
|
|
65
|
+
description: DESCRIPTION,
|
|
66
|
+
whenToUse: WHEN_TO_USE,
|
|
67
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
68
|
+
provider: PROVIDER,
|
|
69
|
+
source: 'bundled',
|
|
70
|
+
path: SKILL_PATH,
|
|
71
|
+
resourceBase: { kind: 'directory', path: SKILL_DIR },
|
|
72
|
+
content,
|
|
73
|
+
}),
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
ctx.effect(() => skills.registerProvider(() => provider), 'dsh-remote: doctor skill')
|
|
77
|
+
return true
|
|
78
|
+
} catch (error) {
|
|
79
|
+
try { ctx.logger?.warn?.('dsh-remote: doctor skill registration failed: ' + (error?.message || String(error))) } catch {}
|
|
80
|
+
return false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function registerDoctorSkill(ctx) {
|
|
85
|
+
// Optional injection declares service access and waits for the registry to
|
|
86
|
+
// become available. True here means the watcher was installed; only the
|
|
87
|
+
// observed registration status proves a provider was registered.
|
|
88
|
+
if (typeof ctx?.inject === 'function') {
|
|
89
|
+
registrations.set(ctx, 'waiting')
|
|
90
|
+
ctx.inject(['skills'], child => {
|
|
91
|
+
registrations.set(ctx, registerProvider(child) ? 'registered' : 'unavailable')
|
|
92
|
+
child.effect(() => () => { registrations.set(ctx, 'waiting') }, 'dsh-remote: doctor registration state')
|
|
93
|
+
})
|
|
94
|
+
return true
|
|
95
|
+
}
|
|
96
|
+
const registered = registerProvider(ctx)
|
|
97
|
+
registrations.set(ctx, registered ? 'registered' : 'unavailable')
|
|
98
|
+
return registered
|
|
99
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// The loaded module determines the diagnosis target. No client path input.
|
|
2
|
+
import {readFileSync,realpathSync} from 'node:fs'
|
|
3
|
+
import {join} from 'node:path'
|
|
4
|
+
import {fileURLToPath} from 'node:url'
|
|
5
|
+
import {doctorSkillStatus} from './doctor-skill.mjs'
|
|
6
|
+
export const DOCTOR_PLUGIN_ROOT = realpathSync(fileURLToPath(new URL('./',import.meta.url)))
|
|
7
|
+
const registries = new WeakMap()
|
|
8
|
+
export function watchDoctorWorkspaces(ctx) {
|
|
9
|
+
if(typeof ctx?.inject!=='function')return
|
|
10
|
+
ctx.inject(['workspaceRegistry'],child=>{
|
|
11
|
+
registries.set(ctx,child.get('workspaceRegistry'))
|
|
12
|
+
child.effect(()=>()=>registries.delete(ctx),'dsh-remote: doctor workspace targets')
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
export function readDoctorTarget(ctx) {
|
|
16
|
+
let version=''
|
|
17
|
+
try { const pkg=JSON.parse(readFileSync(join(DOCTOR_PLUGIN_ROOT,'package.json'),'utf8'));if(pkg.name==='dsh-remote-plugin')version=pkg.version } catch {}
|
|
18
|
+
let workspaces=[]
|
|
19
|
+
try {
|
|
20
|
+
const registry=registries.get(ctx) ?? ctx.get?.('workspaceRegistry') ?? ctx.get?.('workspace'),rows=registry?.list?.()
|
|
21
|
+
if(Array.isArray(rows))workspaces=rows.slice(0,100).filter(row=>typeof row?.id==='string'&&typeof row?.path==='string').map(row=>({workspaceId:row.id.slice(0,200),title:String(row.title||row.name||'').slice(0,200),path:row.path.slice(0,4096)}))
|
|
22
|
+
} catch {}
|
|
23
|
+
return {ok:true,schema:1,plugin:{path:DOCTOR_PLUGIN_ROOT,version,kind:'loaded-plugin'},skill:{name:'dsh-remote-doctor',status:doctorSkillStatus(ctx)},workspaces}
|
|
24
|
+
}
|