universal-plugin-hub 1.5.1 → 1.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/README.md +2 -0
- package/README.zh.md +2 -0
- package/assets/icon.svg +20 -0
- package/client/client.js +1737 -651
- package/package.json +8 -10
- package/scripts/postinstall.js +3 -3
- package/src/hooks.js +1644 -0
- package/src/index.js +93 -9
- package/src/install.js +688 -203
- package/src/local.js +208 -24
- package/src/market.js +66 -9
- package/src/parser.js +198 -32
- package/src/routes.js +197 -50
- package/src/store.js +81 -27
- package/assets/Add-plugin-source.png +0 -0
- package/assets/MCP.png +0 -0
- package/assets/Plugin-management.png +0 -0
- package/assets/Plugins-official.png +0 -0
- package/assets/Skills.png +0 -0
- package/screenshots.json +0 -7
package/src/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Plugin entry point: mounts the HTTP routes once the profile composes
|
|
3
|
-
* the webServer service
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* the webServer service, attaches the native Cordis plugin-hook runtime, and
|
|
4
|
+
* provisions the LSP host packages (`dsh-lsp`, `dsh-lsp-stdio`, `dsh-tool-lsp`)
|
|
5
|
+
* on startup. `scripts/postinstall.js` does the same LSP pre-provisioning during
|
|
6
|
+
* `dsh plugin add`, but package managers gate install scripts behind an approval
|
|
7
|
+
* prompt, so startup is the reliable path.
|
|
8
8
|
*/
|
|
9
9
|
import { mountRoutes } from './routes.js'
|
|
10
10
|
import { cancelAllOAuthVerifications } from './oauth.js'
|
|
11
|
-
import { syncAllInstalledSkillsToDsh, installProfilePackages, findDshMainNodeModules, toolCallIconGroups, LSP_HOST_PACKAGES,
|
|
11
|
+
import { syncAllInstalledSkillsToDsh, installProfilePackages, hasHostPackagesInstalled, findDshMainNodeModules, toolCallIconGroups, LSP_HOST_PACKAGES, migrateLegacyHookBridges } from './install.js'
|
|
12
|
+
import { attachPluginHooksRuntime } from './hooks.js'
|
|
12
13
|
import { createSkillsManager } from './skills.js'
|
|
13
|
-
import { sweepTrash } from './store.js'
|
|
14
|
+
import { sweepTrash, resolveOptionalService } from './store.js'
|
|
14
15
|
import { restoreUploadedSkills } from './skill-uploads.js'
|
|
15
16
|
import { removeDuplicateLocalMarketTabs } from './local.js'
|
|
16
17
|
import { createProfileApplicator } from './runtime.js'
|
|
@@ -22,6 +23,8 @@ import {
|
|
|
22
23
|
} from './at-plugins.js'
|
|
23
24
|
import { createRequire } from 'node:module'
|
|
24
25
|
import { join } from 'node:path'
|
|
26
|
+
import { pathToFileURL } from 'node:url'
|
|
27
|
+
import semver from 'semver'
|
|
25
28
|
|
|
26
29
|
export const name = 'universal-plugin-hub'
|
|
27
30
|
|
|
@@ -34,9 +37,66 @@ export function apply(ctx) {
|
|
|
34
37
|
// Everything below that resolves a profile path has to run *after* this, so
|
|
35
38
|
// it lives inside the injection rather than beside it.
|
|
36
39
|
let provisioned = Promise.resolve()
|
|
40
|
+
let provisionQueue = Promise.resolve()
|
|
41
|
+
let liveDshVersion
|
|
42
|
+
let profileHostCtx = null
|
|
43
|
+
const applyProfile = createProfileApplicator(ctx)
|
|
44
|
+
|
|
45
|
+
function resolveRuntimeDshVersion(hostCtx) {
|
|
46
|
+
const pluginPackages =
|
|
47
|
+
resolveOptionalService(hostCtx, 'pluginPackages') ||
|
|
48
|
+
resolveOptionalService(ctx?.root, 'pluginPackages') ||
|
|
49
|
+
resolveOptionalService(ctx, 'pluginPackages')
|
|
50
|
+
if (pluginPackages && typeof pluginPackages.packageOf === 'function') {
|
|
51
|
+
const anchor = hostCtx?.profileContext?.installAnchor || hostCtx?.profileContext?.patchPath
|
|
52
|
+
const parentURL = anchor ? pathToFileURL(anchor).href : import.meta.url
|
|
53
|
+
for (const pkgName of ['@deepseek-ai/dsh-app-boot', '@deepseek-ai/dsh-session', '@deepseek-ai/dsh']) {
|
|
54
|
+
try {
|
|
55
|
+
const pkg = pluginPackages.packageOf(pkgName, parentURL)
|
|
56
|
+
if (typeof pkg?.version === 'string' && semver.valid(pkg.version.trim())) {
|
|
57
|
+
return pkg.version.trim()
|
|
58
|
+
}
|
|
59
|
+
} catch {}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
ctx.logger?.debug?.('[universal-plugin-hub] unable to resolve live DSH version from pluginPackages; falling back to local install metadata')
|
|
63
|
+
return undefined
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function ensureHostPackages(packages) {
|
|
67
|
+
const list = Array.from(new Set((packages || []).filter((n) => typeof n === 'string' && n.trim())))
|
|
68
|
+
const dshVersion = liveDshVersion ?? resolveRuntimeDshVersion(profileHostCtx || ctx)
|
|
69
|
+
if (list.length === 0 || hasHostPackagesInstalled(list, undefined, dshVersion)) {
|
|
70
|
+
return { ok: true, installed: [] }
|
|
71
|
+
}
|
|
72
|
+
const run = provisionQueue.catch(() => {}).then(async () => {
|
|
73
|
+
await provisioned.catch(() => {})
|
|
74
|
+
const currentDshVersion = liveDshVersion ?? resolveRuntimeDshVersion(profileHostCtx || ctx)
|
|
75
|
+
const missing = list.filter((name) => !hasHostPackagesInstalled([name], undefined, currentDshVersion))
|
|
76
|
+
if (missing.length === 0) return { ok: true, installed: [] }
|
|
77
|
+
try {
|
|
78
|
+
const res = await installProfilePackages(
|
|
79
|
+
missing,
|
|
80
|
+
currentDshVersion !== undefined ? { dshVersion: currentDshVersion } : undefined,
|
|
81
|
+
)
|
|
82
|
+
if (res && !res.ok) {
|
|
83
|
+
ctx.logger?.warn?.(`[universal-plugin-hub] host package provisioning skipped: ${res.error}`)
|
|
84
|
+
}
|
|
85
|
+
return res
|
|
86
|
+
} catch (err) {
|
|
87
|
+
ctx.logger?.warn?.(`[universal-plugin-hub] host package provisioning skipped: ${err.message}`)
|
|
88
|
+
return { ok: false, error: err.message, installed: [] }
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
provisionQueue = run.catch(() => {})
|
|
92
|
+
return run
|
|
93
|
+
}
|
|
94
|
+
|
|
37
95
|
ctx.inject(['profileContext'], async (hostCtx) => {
|
|
96
|
+
profileHostCtx = hostCtx
|
|
38
97
|
const name = hostCtx.profileContext?.name
|
|
39
98
|
if (typeof name === 'string' && name.trim()) process.env.DSH_PROFILE = name.trim()
|
|
99
|
+
liveDshVersion = resolveRuntimeDshVersion(hostCtx)
|
|
40
100
|
|
|
41
101
|
// Ensure all installed plugin skills are immediately synced to $DSH_HOME/skills
|
|
42
102
|
try {
|
|
@@ -54,14 +114,37 @@ export function apply(ctx) {
|
|
|
54
114
|
ctx.logger?.warn?.(`[universal-plugin-hub] skill sync error: ${err.message}`)
|
|
55
115
|
}
|
|
56
116
|
|
|
117
|
+
try {
|
|
118
|
+
const migrated = migrateLegacyHookBridges()
|
|
119
|
+
if (migrated.removed.length > 0 || migrated.synced.length > 0) {
|
|
120
|
+
ctx.logger?.info?.(
|
|
121
|
+
`[universal-plugin-hub] migrated native hooks (removed=${migrated.removed.length}, synced=${migrated.synced.length})`,
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
if (migrated.removed.length > 0) {
|
|
125
|
+
applyProfile()
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
ctx.logger?.warn?.(`[universal-plugin-hub] hook migration error: ${err.message}`)
|
|
129
|
+
}
|
|
130
|
+
|
|
57
131
|
// Host packages disappear when a package manager re-resolves the profile
|
|
58
132
|
// (pnpm moves unrecognized packages to node_modules/.ignored), so repair
|
|
59
133
|
// them on every start instead of trusting a one-time install step.
|
|
60
134
|
// Detached on purpose: Cordis awaits whatever apply returns, and this does
|
|
61
135
|
// network probes and tarball extraction — the hub fiber must not wait on it.
|
|
62
136
|
// Exposed on the callback for tests that need to await it.
|
|
63
|
-
const
|
|
137
|
+
const startupOptions = liveDshVersion !== undefined ? { dshVersion: liveDshVersion } : undefined
|
|
138
|
+
const provisioning = installProfilePackages([...LSP_HOST_PACKAGES], startupOptions).then((res) => {
|
|
139
|
+
if (res && !res.ok) {
|
|
140
|
+
ctx.logger?.warn?.(`[universal-plugin-hub] host package provisioning skipped: ${res.error}`)
|
|
141
|
+
} else if (res?.installed?.length > 0) {
|
|
142
|
+
ctx.logger?.info?.(`[universal-plugin-hub] provisioned host packages (${res.installed.join(', ')})`)
|
|
143
|
+
}
|
|
144
|
+
return res
|
|
145
|
+
}).catch((err) => {
|
|
64
146
|
ctx.logger?.warn?.(`[universal-plugin-hub] host package provisioning skipped: ${err.message}`)
|
|
147
|
+
return { ok: false, error: err.message, installed: [] }
|
|
65
148
|
})
|
|
66
149
|
provisioned = provisioning
|
|
67
150
|
})
|
|
@@ -90,13 +173,14 @@ export function apply(ctx) {
|
|
|
90
173
|
})
|
|
91
174
|
ctx.inject(['agents'], (hostCtx) => {
|
|
92
175
|
hostCtx.effect(() => attachAtPluginsAgentHook(hostCtx), 'universal-plugin-hub: @ plugins routing')
|
|
176
|
+
hostCtx.effect(() => attachPluginHooksRuntime(hostCtx), 'universal-plugin-hub: native plugin hooks')
|
|
93
177
|
})
|
|
94
178
|
ctx.inject(['sessions'], (hostCtx) => {
|
|
95
179
|
hostCtx.effect(() => attachAtPluginsSessionTitleHook(hostCtx), 'universal-plugin-hub: @ plugins session title')
|
|
96
180
|
})
|
|
97
181
|
ctx.inject(['webServer'], (hostCtx) => {
|
|
98
182
|
hostCtx.effect(() => {
|
|
99
|
-
const unmount = mountRoutes(hostCtx.webServer, skills,
|
|
183
|
+
const unmount = mountRoutes(hostCtx.webServer, skills, applyProfile, ensureHostPackages)
|
|
100
184
|
const offBoot = hostCtx.on?.('webserver/index-inject', (table) => {
|
|
101
185
|
try {
|
|
102
186
|
const value = []
|