feat: add DSH plugin marketplace and shared MCP
GoodBuddy could share Skills across runtimes, but custom MCP remained limited and DeepSeek Harness could not manage third-party extensions. The app now provides a default-off DSH npm marketplace with managed installation, configuration, failure isolation, and packaged npm support, while assigned custom MCP is available to managed OpenCode, Continue Agent, and DeepSeek Harness in Execute. Third-party DSH install scripts, initialization, and tools run with the current user's permissions. Ask remains read-only at dispatch, and turning off the marketplace hides management without disabling installed plugins. Release note: 新增默认关闭的 DSH 插件市场,并让自定义 MCP 可分配给 OpenCode、Continue 和 DeepSeek Harness;安装第三方插件前会明确提示当前用户权限边界。
This commit is contained in:
+67
-1
@@ -69,7 +69,10 @@ const portableRequiredFiles = [
|
||||
'resources/icon.ico',
|
||||
'resources/tray-icon.png',
|
||||
'resources/runtimes/opencode/opencode.exe',
|
||||
'resources/runtimes/continue/package.json'
|
||||
'resources/runtimes/continue/package.json',
|
||||
'resources/runtimes/npm/bin/npm-cli.js',
|
||||
'resources/runtimes/npm/package.json',
|
||||
'resources/runtimes/npm/node_modules/graceful-fs/package.json'
|
||||
]
|
||||
const maxPortableZipEntries = 50_000
|
||||
const maxPortableCentralDirectoryBytes = 64 * 1024 * 1024
|
||||
@@ -441,6 +444,20 @@ function assertFile(filePath, description) {
|
||||
}
|
||||
}
|
||||
|
||||
function readJsonFile(filePath, description) {
|
||||
assertFile(filePath, description)
|
||||
try {
|
||||
return JSON.parse(readFileSync(filePath, 'utf8'))
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`${description}无效:${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}`,
|
||||
{ cause: error }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeAsarEntry(filePath) {
|
||||
return filePath.split('/').join(sep)
|
||||
}
|
||||
@@ -795,6 +812,45 @@ function verifyHarnessPackage(
|
||||
)
|
||||
}
|
||||
}
|
||||
const npmRoot = join(resources, 'runtimes', 'npm')
|
||||
const npmManifest = readJsonFile(
|
||||
join(npmRoot, 'package.json'),
|
||||
'DSH 插件安装 npm 元数据'
|
||||
)
|
||||
if (npmManifest.version !== packageJson.dependencies?.npm) {
|
||||
throw new Error(
|
||||
`DSH 插件安装 npm 版本错误:期望 ${String(packageJson.dependencies?.npm)},实际 ${String(npmManifest.version)}`
|
||||
)
|
||||
}
|
||||
assertFile(
|
||||
join(npmRoot, 'bin', 'npm-cli.js'),
|
||||
'DSH 插件安装 npm CLI'
|
||||
)
|
||||
if (
|
||||
!Array.isArray(npmManifest.bundleDependencies) ||
|
||||
npmManifest.bundleDependencies.length === 0
|
||||
) {
|
||||
throw new Error('DSH 插件安装 npm 依赖清单无效')
|
||||
}
|
||||
for (const packageName of npmManifest.bundleDependencies) {
|
||||
if (
|
||||
typeof packageName !== 'string' ||
|
||||
!/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u.test(
|
||||
packageName
|
||||
)
|
||||
) {
|
||||
throw new Error('DSH 插件安装 npm 依赖清单无效')
|
||||
}
|
||||
assertFile(
|
||||
join(
|
||||
npmRoot,
|
||||
'node_modules',
|
||||
...packageName.split('/'),
|
||||
'package.json'
|
||||
),
|
||||
`DSH 插件安装 npm 依赖 ${packageName}`
|
||||
)
|
||||
}
|
||||
const targetKoffiManifest = readJson(
|
||||
`node_modules/${target.koffiPackage}/package.json`,
|
||||
`${target.koffiPackage} 元数据`
|
||||
@@ -903,6 +959,16 @@ function verifyUnpackedOutput(directory, options) {
|
||||
join(resources, 'runtimes', 'continue', 'dist', 'index.js'),
|
||||
'Continue Runtime'
|
||||
)
|
||||
assertFile(
|
||||
join(
|
||||
resources,
|
||||
'runtimes',
|
||||
'npm',
|
||||
'bin',
|
||||
'npm-cli.js'
|
||||
),
|
||||
'DSH 插件安装 npm Runtime'
|
||||
)
|
||||
verifyHarnessPackage(resources, options)
|
||||
for (const [filePath, label] of [
|
||||
[applicationExecutable, '应用主程序'],
|
||||
|
||||
@@ -184,6 +184,7 @@ async function run() {
|
||||
harnessVersion: '0.1.0-rc.6',
|
||||
credentialRefs: ['GOODBUDDY_HARNESS_MODEL_API_KEY'],
|
||||
skillPackages: [],
|
||||
extensionPackages: [],
|
||||
maxFrameBytes: 1024 * 1024
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const { spawn } = require('node:child_process')
|
||||
const {
|
||||
chmod,
|
||||
copyFile,
|
||||
mkdir,
|
||||
mkdtemp,
|
||||
@@ -11,7 +12,7 @@ const {
|
||||
} = require('node:fs/promises')
|
||||
const { statSync } = require('node:fs')
|
||||
const { tmpdir } = require('node:os')
|
||||
const { join, resolve } = require('node:path')
|
||||
const { delimiter, join, resolve } = require('node:path')
|
||||
|
||||
const unpackedPath = process.argv[2]
|
||||
? resolve(process.argv[2])
|
||||
@@ -28,20 +29,57 @@ const host = join(
|
||||
'main',
|
||||
'deepseek-harness-host-bootstrap.js'
|
||||
)
|
||||
const npmRoot = join(unpackedPath, 'resources', 'runtimes', 'npm')
|
||||
const npmCli = join(npmRoot, 'bin', 'npm-cli.js')
|
||||
const npmManifestPath = join(npmRoot, 'package.json')
|
||||
|
||||
for (const [path, description] of [
|
||||
[executable, 'packaged Electron executable'],
|
||||
[host, 'packaged DeepSeek Harness host']
|
||||
[host, 'packaged DeepSeek Harness host'],
|
||||
[npmCli, 'packaged npm CLI'],
|
||||
[npmManifestPath, 'packaged npm manifest']
|
||||
]) {
|
||||
if (!statSync(path, { throwIfNoEntry: false })?.isFile()) {
|
||||
throw new Error(`${description} is missing: ${path}`)
|
||||
}
|
||||
}
|
||||
|
||||
function run(command, args, env) {
|
||||
function quotePosixShell(value) {
|
||||
return `'${value.replaceAll("'", "'\\''")}'`
|
||||
}
|
||||
|
||||
async function prepareNodeCommand(directory) {
|
||||
await mkdir(directory, { recursive: true })
|
||||
if (process.platform === 'win32') {
|
||||
await writeFile(
|
||||
join(directory, 'node.cmd'),
|
||||
[
|
||||
'@echo off',
|
||||
'set "ELECTRON_RUN_AS_NODE=1"',
|
||||
`"${executable.replaceAll('%', '%%')}" %*`,
|
||||
''
|
||||
].join('\r\n'),
|
||||
'utf8'
|
||||
)
|
||||
return
|
||||
}
|
||||
const commandPath = join(directory, 'node')
|
||||
await writeFile(
|
||||
commandPath,
|
||||
[
|
||||
'#!/bin/sh',
|
||||
`ELECTRON_RUN_AS_NODE=1 exec ${quotePosixShell(executable)} "$@"`,
|
||||
''
|
||||
].join('\n'),
|
||||
'utf8'
|
||||
)
|
||||
await chmod(commandPath, 0o700)
|
||||
}
|
||||
|
||||
function run(command, args, env, cwd = resolve('.')) {
|
||||
return new Promise((resolveExit, rejectExit) => {
|
||||
const child = spawn(command, args, {
|
||||
cwd: resolve('.'),
|
||||
cwd,
|
||||
env,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
windowsHide: true
|
||||
@@ -67,6 +105,9 @@ async function main() {
|
||||
const project = join(root, 'app')
|
||||
const profile = join(root, 'profile')
|
||||
const resultPath = join(root, 'result.json')
|
||||
const packageManagerBin = join(root, 'package-manager-bin')
|
||||
const npmProject = join(root, 'npm-project')
|
||||
const npmFixture = join(root, 'npm-fixture')
|
||||
await mkdir(project, { recursive: true })
|
||||
|
||||
await copyFile(
|
||||
@@ -116,9 +157,16 @@ async function main() {
|
||||
'never',
|
||||
`--config.directories.output=${join(root, 'dist')}`
|
||||
]
|
||||
if (process.env.GOODBUDDY_ELECTRON_DIST) {
|
||||
const electronDist = process.env.GOODBUDDY_ELECTRON_DIST
|
||||
? resolve(process.env.GOODBUDDY_ELECTRON_DIST)
|
||||
: resolve('node_modules/electron/dist')
|
||||
if (
|
||||
statSync(electronDist, {
|
||||
throwIfNoEntry: false
|
||||
})?.isDirectory()
|
||||
) {
|
||||
packageArguments.push(
|
||||
`--config.electronDist=${resolve(process.env.GOODBUDDY_ELECTRON_DIST)}`
|
||||
`--config.electronDist=${electronDist}`
|
||||
)
|
||||
}
|
||||
const packaged = await run(
|
||||
@@ -153,7 +201,102 @@ async function main() {
|
||||
`Packaged DeepSeek Harness smoke failed (${executed.exitCode}, ${executed.signal ?? 'no signal'}): ${JSON.stringify(result)} ${executed.output.trim()}`
|
||||
)
|
||||
}
|
||||
|
||||
const npmManifest = JSON.parse(
|
||||
await readFile(npmManifestPath, 'utf8')
|
||||
)
|
||||
await prepareNodeCommand(packageManagerBin)
|
||||
await mkdir(npmProject, { recursive: true })
|
||||
await mkdir(npmFixture, { recursive: true })
|
||||
await writeFile(
|
||||
join(npmProject, 'package.json'),
|
||||
'{"name":"goodbuddy-packaged-npm-project","version":"1.0.0","private":true}\n',
|
||||
'utf8'
|
||||
)
|
||||
await writeFile(
|
||||
join(npmFixture, 'package.json'),
|
||||
`${JSON.stringify({
|
||||
name: 'goodbuddy-packaged-npm-smoke',
|
||||
version: '1.0.0',
|
||||
scripts: {
|
||||
install: 'node install.cjs'
|
||||
}
|
||||
})}\n`,
|
||||
'utf8'
|
||||
)
|
||||
await writeFile(
|
||||
join(npmFixture, 'install.cjs'),
|
||||
"require('node:fs').writeFileSync(require('node:path').join(__dirname, 'lifecycle-ran.txt'), 'ready\\n')\n",
|
||||
'utf8'
|
||||
)
|
||||
const inheritedPath =
|
||||
process.env.PATH ?? process.env.Path ?? ''
|
||||
const npmEnvironment = {
|
||||
...process.env,
|
||||
PATH: inheritedPath
|
||||
? `${packageManagerBin}${delimiter}${inheritedPath}`
|
||||
: packageManagerBin,
|
||||
Path: inheritedPath
|
||||
? `${packageManagerBin}${delimiter}${inheritedPath}`
|
||||
: packageManagerBin,
|
||||
ELECTRON_RUN_AS_NODE: '1',
|
||||
npm_execpath: npmCli,
|
||||
npm_node_execpath: executable,
|
||||
npm_config_audit: 'false',
|
||||
npm_config_fund: 'false',
|
||||
npm_config_update_notifier: 'false'
|
||||
}
|
||||
const npmVersion = await run(
|
||||
executable,
|
||||
[npmCli, '--version'],
|
||||
npmEnvironment,
|
||||
npmProject
|
||||
)
|
||||
if (
|
||||
npmVersion.exitCode !== 0 ||
|
||||
npmVersion.signal ||
|
||||
npmVersion.output.trim() !== npmManifest.version
|
||||
) {
|
||||
throw new Error(
|
||||
`Packaged npm version smoke failed: ${npmVersion.output.trim()}`
|
||||
)
|
||||
}
|
||||
const installed = await run(
|
||||
executable,
|
||||
[
|
||||
npmCli,
|
||||
'install',
|
||||
'--save-exact',
|
||||
'--no-audit',
|
||||
'--no-fund',
|
||||
'--dangerously-allow-all-scripts',
|
||||
'--loglevel=error',
|
||||
npmFixture
|
||||
],
|
||||
npmEnvironment,
|
||||
npmProject
|
||||
)
|
||||
if (installed.exitCode !== 0 || installed.signal) {
|
||||
throw new Error(
|
||||
`Packaged npm install smoke failed: ${installed.output.trim()}`
|
||||
)
|
||||
}
|
||||
const lifecycleMarker = await readFile(
|
||||
join(
|
||||
npmProject,
|
||||
'node_modules',
|
||||
'goodbuddy-packaged-npm-smoke',
|
||||
'lifecycle-ran.txt'
|
||||
),
|
||||
'utf8'
|
||||
)
|
||||
if (lifecycleMarker !== 'ready\n') {
|
||||
throw new Error('Packaged npm lifecycle smoke failed')
|
||||
}
|
||||
console.log('Packaged DeepSeek Harness utility smoke: ready')
|
||||
console.log(
|
||||
`Packaged npm install smoke: ready (${npmManifest.version})`
|
||||
)
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user