Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

feat(ssh): 远端补 pnpm 垫片、内置插件退出同步清单、版本规格补包名

Menghuan1918f1c756504949
diff --git a/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts b/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts
index bf99371f..bd80a479 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts
@@ -63,11 +63,11 @@ export const zh = {
'remove.confirm.ok': '确认删除',
'bridge.error': '打开远端窗口失败:',
'sync.title': '同步到远端',
- 'sync.desc': '把本机档案里的插件与用户级 Skill 推到一台已连接的机器:插件在远端执行 dsh plugin add;Skill 经 tar 流式写入远端 ~/.dsh/skills。同步前可在下面勾选要带走的内容。',
+ 'sync.desc': '把本机档案里的第三方插件与用户级 Skill 推到一台已连接的机器:插件在远端执行 dsh plugin add;Skill 经 tar 流式写入远端 ~/.dsh/skills。桌面内置插件(dsh-tauri-*)在连接时已自动同步,故不在此列出。',
'sync.target': '目标机器',
'sync.plugins': '插件',
'sync.skills': 'Skill',
- 'sync.noPlugins': '本机档案没有可同步的插件依赖。',
+ 'sync.noPlugins': '本机没有第三方插件需要同步(桌面内置插件连接时已自动同步)。',
'sync.noSkills': '没有用户级 Skill。',
'sync.selected': '已选 {plugins} 个插件、{skills} 个 Skill',
'sync.selectAll': '全选',
@@ -179,11 +179,11 @@ export const en = {
'remove.confirm.ok': 'Remove it',
'bridge.error': 'Failed to open the remote window: ',
'sync.title': 'Sync to remote',
- 'sync.desc': 'Push the plugins and user-level skills of this machine\'s profile to a connected machine: plugins install remotely via dsh plugin add; skills stream as a tar into the remote ~/.dsh/skills. Tick what should travel below.',
+ 'sync.desc': 'Push this profile\'s third-party plugins and user-level skills to a connected machine: plugins install remotely via dsh plugin add; skills stream as a tar into the remote ~/.dsh/skills. Desktop-bundled plugins (dsh-tauri-*) already sync on connect, so they are not listed.',
'sync.target': 'Target machine',
'sync.plugins': 'Plugins',
'sync.skills': 'Skills',
- 'sync.noPlugins': 'No syncable plugin dependencies in the local profile.',
+ 'sync.noPlugins': 'No third-party plugins to sync (desktop-bundled ones already sync on connect).',
'sync.noSkills': 'No user-level skills.',
'sync.selected': '{plugins} plugins and {skills} skills selected',
'sync.selectAll': 'Select all',
diff --git a/packages/dsh-tauri-ssh/src/host/service/bootstrap.test.ts b/packages/dsh-tauri-ssh/src/host/service/bootstrap.test.ts
index 73f3a5b2..7591865a 100644
--- a/packages/dsh-tauri-ssh/src/host/service/bootstrap.test.ts
+++ b/packages/dsh-tauri-ssh/src/host/service/bootstrap.test.ts
@@ -17,6 +17,7 @@ import {
createBootstrapLineDispatcher,
credentialsCopyCommand,
describeExecFailure,
+ ensurePnpmCommand,
ensureRemoteInstance,
firstLineOf,
legacyProbeCommand,
@@ -530,6 +531,55 @@ describe('install script execution (real POSIX sh)', () => {
})
})
+describe('remote pnpm shim (real POSIX sh)', () => {
+ /** Run a generated command under the real `sh` inside a sandboxed HOME. */
+ async function runCommand(command: string, sandbox: string): Promise<{ code: number, stdout: string, stderr: string }> {
+ const scriptPath = join(sandbox, 'command.sh')
+ writeFileSync(scriptPath, command)
+ const run = promisify(execFile)
+ return run('sh', [scriptPath], { env: { ...process.env, HOME: sandbox } }).then(
+ ({ stdout, stderr }) => ({ code: 0, stdout, stderr }),
+ (error: { code?: number, stdout?: string, stderr?: string }) =>
+ ({ code: error.code ?? -1, stdout: error.stdout ?? '', stderr: error.stderr ?? '' }),
+ )
+ }
+
+ it('writes a shim that runs the layout pnpm under the layout node', async () => {
+ const sandbox = mkdtempSync(join(tmpdir(), 'pnpm-shim-'))
+ try {
+ const bin = join(sandbox, REMOTE_ROOT, 'runtime', 'bin')
+ const entry = join(sandbox, REMOTE_ROOT, 'dependencies', 'pnpm', 'bin', 'pnpm.cjs')
+ mkdirSync(bin, { recursive: true })
+ mkdirSync(join(sandbox, REMOTE_ROOT, 'dependencies', 'pnpm', 'bin'), { recursive: true })
+ // 布局里的 node 与 pnpm 用桩件代替:断言垫片确实按「布局 node + 布局 pnpm」转发
+ writeFileSync(join(bin, 'node'), `#!/bin/sh\nprintf 'node:%s\\n' "$*"\n`)
+ chmodSync(join(bin, 'node'), 0o755)
+ writeFileSync(entry, 'stub')
+
+ const first = await runCommand(ensurePnpmCommand(), sandbox)
+ expect(first.code).toBe(0)
+ const shim = join(bin, 'pnpm')
+ expect(existsSync(shim)).toBe(true)
+ expect(statSync(shim).mode & 0o111).not.toBe(0)
+ expect(readFileSync(shim, 'utf8')).toContain(`exec "$HOME/${REMOTE_ROOT}/runtime/bin/node" "$HOME/${REMOTE_ROOT}/dependencies/pnpm/bin/pnpm.cjs" "$@"`)
+
+ // 垫片可执行,并按布局 node + 布局 pnpm 转发参数
+ const forwarded = await runCommand(`"${shim}" install --prod`, sandbox)
+ expect(forwarded.stdout).toContain(`node:${entry} install --prod`)
+
+ // 幂等:已有垫片不再改写(改成哨兵内容后重跑,内容保持不变)
+ writeFileSync(shim, '#!/bin/sh\necho sentinel\n')
+ chmodSync(shim, 0o755)
+ const second = await runCommand(ensurePnpmCommand(), sandbox)
+ expect(second.code).toBe(0)
+ expect(readFileSync(shim, 'utf8')).toContain('sentinel')
+ }
+ finally {
+ rmSync(sandbox, { recursive: true, force: true })
+ }
+ })
+})
+
describe('component probe and launch commands', () => {
it('lists the missing components of the remote layout', () => {
const command = checkMissingCommand()
diff --git a/packages/dsh-tauri-ssh/src/host/service/bootstrap.ts b/packages/dsh-tauri-ssh/src/host/service/bootstrap.ts
index 2d33fefc..8df90b29 100644
--- a/packages/dsh-tauri-ssh/src/host/service/bootstrap.ts
+++ b/packages/dsh-tauri-ssh/src/host/service/bootstrap.ts
@@ -506,6 +506,32 @@ export function layoutNodeBinary(): string {
return `"$HOME/${REMOTE_ROOT}/runtime/bin/node"`
}
+/**
+ * The layout's shared bin directory (unquoted; `$HOME` expands in the remote
+ * shell). It is already on the remote instance's PATH — the start command
+ * exports it — so anything placed here is visible to the instance's own
+ * tooling as well.
+ */
+export function layoutBinDir(): string {
+ return `$HOME/${REMOTE_ROOT}/runtime/bin`
+}
+
+/**
+ * Make the layout's bundled pnpm reachable as a bare `pnpm` on PATH.
+ *
+ * `dsh plugin add` shells out to `pnpm`, but a stock remote install only
+ * ships the binary at `dependencies/pnpm/bin/pnpm.cjs` (the installer uses it
+ * by absolute path) — nothing named `pnpm` exists, so every plugin install
+ * died with `exit 127: dsh: pnpm not found on PATH`. The shim is written
+ * once (an existing one is left alone), runs the layout's own Node and pnpm,
+ * and needs no network: the version is the one the installer already pinned
+ * ({@link PNPM_VERSION}).
+ */
+export function ensurePnpmCommand(): string {
+ const shim = `#!/bin/sh\nexec "$HOME/${REMOTE_ROOT}/runtime/bin/node" "$HOME/${REMOTE_ROOT}/dependencies/pnpm/${PNPM_ENTRY}" "$@"\n`
+ return `B="${layoutBinDir()}"; [ -x "$B/pnpm" ] || { mkdir -p "$B" && printf %s ${shQuote(shim)} > "$B/pnpm" && chmod +x "$B/pnpm"; }`
+}
+
/**
* The installed dsh-entry probe for command-driving callers (the sync
* engine): prints the first entry the binary layout actually holds — zip
diff --git a/packages/dsh-tauri-ssh/src/host/service/manager.test.ts b/packages/dsh-tauri-ssh/src/host/service/manager.test.ts
index e23fba77..c9c314c7 100644
--- a/packages/dsh-tauri-ssh/src/host/service/manager.test.ts
+++ b/packages/dsh-tauri-ssh/src/host/service/manager.test.ts
@@ -92,7 +92,7 @@ class FakeSession implements SshSession {
private closedCallbacks: Array<() => void> = []
constructor(
- public healthHealthy: (commandIndex: number) => boolean,
+ public healthHealthy: (probeIndex: number) => boolean,
public connectError?: Error,
public startError?: Error,
public installError?: Error,
@@ -144,11 +144,16 @@ class FakeSession implements SshSession {
return { code: 127, stdout: '', stderr: this.startError.message }
return { code: 0, stdout: '远端实例已拉起', stderr: '' }
}
- const healthy = this.healthHealthy(this.commands.length - 1)
+ // 探测序号而非命令序号:连接流程里插入与探测无关的命令(pnpm 垫片)不该
+ // 移动「第几次探测」的语义,否则守卫用例会被无关改动带崩。计数只在探测
+ // 分支里推进——落到兜底返回的命令不是探测。
if (command.includes('/dev/null')) {
- return healthy ? { code: 0, stdout: '200', stderr: '' } : { code: 7, stdout: '', stderr: 'refused' }
+ return this.healthHealthy(this.probesAnswered++)
+ ? { code: 0, stdout: '200', stderr: '' }
+ : { code: 7, stdout: '', stderr: 'refused' }
}
if (command.includes('curl')) {
+ const healthy = this.healthHealthy(this.probesAnswered++)
if (!healthy)
return { code: 7, stdout: '', stderr: 'refused' }
// The bundle probe (status-suffixed) answers JavaScript; the root
@@ -165,6 +170,9 @@ class FakeSession implements SshSession {
return gate.then(respond)
}
+ /** Probes answered so far (the health predicate's argument). */
+ private probesAnswered = 0
+
/** The stdout the credentials-copy command answers (default: copied). */
credentialsAnswer = 'copied'
@@ -245,6 +253,15 @@ afterEach(() => {
for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })
})
+/**
+ * The bootstrap flow's own commands, without the connect-time prelude (the
+ * idempotent pnpm-shim write). Flow assertions stay about the bootstrap, and
+ * a new prelude step never renumbers them.
+ */
+function bootstrapFlowCommands(session: FakeSession): string[] {
+ return session.commands.filter(command => !command.includes('chmod +x "$B/pnpm"'))
+}
+
/** Wait until the predicate holds (background reconnect races). */
async function until(predicate: () => boolean, label: string): Promise<void> {
const deadline = Date.now() + 2000
@@ -355,11 +372,12 @@ describe('sshManager', () => {
const session = new FakeSession(index => index !== 0)
const { manager } = boot({ sessionFactory: () => session })
await manager.connect(MachineId('m1'))
- expect(session.commands[0]).toContain('curl')
- expect(session.commands[1]).toBe('uname -srm')
- expect(session.commands[2]).toContain('echo node')
- expect(session.commands[3]).toContain('dsh-remote.pid')
- expect(session.commands[3]).toContain('--host 127.0.0.1')
+ const flow = bootstrapFlowCommands(session)
+ expect(flow[0]).toContain('curl')
+ expect(flow[1]).toBe('uname -srm')
+ expect(flow[2]).toContain('echo node')
+ expect(flow[3]).toContain('dsh-remote.pid')
+ expect(flow[3]).toContain('--host 127.0.0.1')
expect(manager.status(MachineId('m1')).state).toBe('connected')
})
@@ -371,6 +389,17 @@ describe('sshManager', () => {
expect(manager.profileName(MachineId('unknown'))).toBe('remote')
})
+ it('writes the remote pnpm shim on connect and reports it on the event channel', async () => {
+ const session = new FakeSession(index => index !== 0)
+ const { manager, events } = boot({ sessionFactory: () => session })
+ await manager.connect(MachineId('m1'))
+ const ensure = session.commands.find(command => command.includes('dependencies/pnpm/bin/pnpm.cjs'))
+ expect(ensure).toBeDefined()
+ expect(ensure).toContain('chmod +x')
+ const lines = events.since(MachineId('m1')).events.map(event => event.line)
+ expect(lines.some(line => line.includes('pnpm 垫片就绪'))).toBe(true)
+ })
+
it('publishes and clears externally driven progress (the sync engine)', () => {
const { manager, emits } = boot()
manager.setProgress(MachineId('m1'), { phase: 'syncing', attempt: 3, total: 13, item: 'dsh-tauri-ssh' })
@@ -803,7 +832,7 @@ describe('sshManager install', () => {
let sessions = 0
const factory = () => {
sessions += 1
- const session = new FakeSession(index => sessions === 2 && index >= 4)
+ const session = new FakeSession(index => sessions === 2 && index >= 1)
if (sessions === 1)
session.missingResult = 'node\ndsh\npnpm\n'
return session
@@ -1183,7 +1212,7 @@ describe('sshManager install', () => {
let sessions = 0
const factory = () => {
sessions += 1
- const session = new FakeSession(index => sessions >= 2 && index >= 4)
+ const session = new FakeSession(index => sessions >= 2 && index >= 1)
// The first (failed) connect finds the runtime incomplete; the install
// and the auto-connect see it whole.
if (sessions === 1)
diff --git a/packages/dsh-tauri-ssh/src/host/service/manager.ts b/packages/dsh-tauri-ssh/src/host/service/manager.ts
index 4886352a..21401fe5 100644
--- a/packages/dsh-tauri-ssh/src/host/service/manager.ts
+++ b/packages/dsh-tauri-ssh/src/host/service/manager.ts
@@ -19,7 +19,7 @@ import { homedir } from 'node:os'
import process from 'node:process'
import { join } from 'pathe'
import { MachineId, SshError } from '../types/index'
-import { checkMissingCommand, credentialsCopyCommand, describeError, describeExecFailure, ensureRemoteInstance, firstLineOf, missingComponentsOf, planRemoteInstall, readEnvCredentials, REMOTE_ROOT, remoteWebTokenCommand, runInstallScript, safeProfileName, skippedVerificationSummary } from './bootstrap'
+import { checkMissingCommand, credentialsCopyCommand, describeError, describeExecFailure, ensurePnpmCommand, ensureRemoteInstance, firstLineOf, missingComponentsOf, planRemoteInstall, readEnvCredentials, REMOTE_ROOT, remoteWebTokenCommand, runInstallScript, safeProfileName, skippedVerificationSummary } from './bootstrap'
import { fingerprintHostKey } from './host-keys'
import { syncBundledPlugins } from './plugins-sync'
import { mintTunnelCookie } from './transport'
@@ -450,6 +450,16 @@ export class SshManager {
catch (error) {
this.deps.events.append(machineId, 'install', `捆绑插件同步失败(降级原生 UI): ${describeError(error)}`)
}
+ // 远端自带的 pnpm 只在 dependencies/pnpm 下,PATH 上没有裸 `pnpm`——而
+ // `dsh plugin add`(同步面板装第三方插件、远端自己装插件)都找它。补一个
+ // 指向布局自带 pnpm 的垫片(幂等、不需联网),失败只记一行日志。
+ try {
+ await session.exec(ensurePnpmCommand())
+ this.deps.events.append(machineId, 'install', '远端 pnpm 垫片就绪(dsh plugin 依赖它)')
+ }
+ catch (error) {
+ this.deps.events.append(machineId, 'install', `远端 pnpm 垫片写入失败: ${describeError(error)}`)
+ }
try {
await ensureRemoteInstance(
session,
diff --git a/packages/dsh-tauri-ssh/src/host/service/sync.test.ts b/packages/dsh-tauri-ssh/src/host/service/sync.test.ts
index 50f477f1..63c625dc 100644
--- a/packages/dsh-tauri-ssh/src/host/service/sync.test.ts
+++ b/packages/dsh-tauri-ssh/src/host/service/sync.test.ts
@@ -4,7 +4,7 @@ import { describe, expect, it, vi } from 'vitest'
import { DEFAULT_REMOTE_PROFILE } from '../storage/index'
import { MachineId } from '../types/index'
import { layoutNodeBinary } from './bootstrap'
-import { buildPreview, classifySpec, pluginAddCommand, skillExtractCommand, SyncEngine } from './sync'
+import { buildPreview, classifySpec, installSpecOf, pluginAddCommand, skillExtractCommand, SyncEngine } from './sync'
/** A scripted SSH session: commands dispatched by order or by matcher. */
function fakeSession(respond: (command: string, options?: { stdinData?: Buffer }) => SshExecResult): SshSession & { execSpy: ReturnType<typeof vi.fn>, closed: () => boolean } {
@@ -79,15 +79,25 @@ describe('buildPreview', () => {
describe('command builders', () => {
it('runs the layout entry under the layout node, both quoted', () => {
expect(pluginAddCommand('/home/u/.dsh-desktop/dependencies/dsh/lib/bin.js', 'github:a/b'))
- .toBe(`"$HOME/.dsh-desktop/runtime/bin/node" '/home/u/.dsh-desktop/dependencies/dsh/lib/bin.js' plugin --profile '${DEFAULT_REMOTE_PROFILE}' add 'github:a/b'`)
+ .toBe(`PATH="$HOME/.dsh-desktop/runtime/bin:$PATH" "$HOME/.dsh-desktop/runtime/bin/node" '/home/u/.dsh-desktop/dependencies/dsh/lib/bin.js' plugin --profile '${DEFAULT_REMOTE_PROFILE}' add 'github:a/b'`)
expect(pluginAddCommand('/home/u/.dsh-desktop/dependencies/dsh/node_modules/@deepseek-ai/dsh/lib/bin.js', 'pkg@^1.0.0'))
- .toBe(`${layoutNodeBinary()} '/home/u/.dsh-desktop/dependencies/dsh/node_modules/@deepseek-ai/dsh/lib/bin.js' plugin --profile '${DEFAULT_REMOTE_PROFILE}' add 'pkg@^1.0.0'`)
+ .toBe(`PATH="$HOME/.dsh-desktop/runtime/bin:$PATH" ${layoutNodeBinary()} '/home/u/.dsh-desktop/dependencies/dsh/node_modules/@deepseek-ai/dsh/lib/bin.js' plugin --profile '${DEFAULT_REMOTE_PROFILE}' add 'pkg@^1.0.0'`)
})
it('installs into the machine profile it is handed, quoted', () => {
// 隧道只服务这台机器自己的档案:装到别处(历史上的硬编码 web)等于没同步
expect(pluginAddCommand('/x/bin.js', 'github:a/b', 'work'))
- .toBe(`${layoutNodeBinary()} '/x/bin.js' plugin --profile 'work' add 'github:a/b'`)
+ .toBe(`PATH="$HOME/.dsh-desktop/runtime/bin:$PATH" ${layoutNodeBinary()} '/x/bin.js' plugin --profile 'work' add 'github:a/b'`)
+ })
+
+ it('composes the install argument: git specs stand alone, version specs need the name', () => {
+ expect(installSpecOf('dsh-market', 'github:omdsh-dev/dsh-market')).toBe('github:omdsh-dev/dsh-market')
+ expect(installSpecOf('p', 'git+https://github.com/a/b.git')).toBe('git+https://github.com/a/b.git')
+ expect(installSpecOf('p', '[email protected]:a/b.git')).toBe('[email protected]:a/b.git')
+ // 裸范围在远端会被 pnpm 拒(实测 `add '^1.31.1'` 失败、`add 'dshmarket@^1.31.1'` 成功)
+ expect(installSpecOf('dshmarket', '^1.31.1')).toBe('dshmarket@^1.31.1')
+ expect(installSpecOf('p', ' latest ')).toBe('p@latest')
+ expect(installSpecOf('p', '0.16.0')).toBe('[email protected]')
})
it('extracts the streamed tarball into the remote skill home', () => {
@@ -229,6 +239,23 @@ describe('syncEngine.apply', () => {
expect(deduped.items).toHaveLength(2)
})
+ it('installs a version-pinned plugin under its package name', async () => {
+ const session = fakeSession((command) => {
+ if (command.includes('printf'))
+ return ok('/dsh\n')
+ return ok()
+ })
+ const sync = new SyncEngine({
+ profileDependencies: () => ({}),
+ scanSkills: () => [],
+ packSkills: async () => Buffer.alloc(0),
+ openSession: async () => session,
+ })
+ await sync.apply(machine, [{ name: 'dshmarket', spec: '^1.31.1' }], [])
+ const add = session.execSpy.mock.calls.map(([command]) => command).find(command => command.includes('plugin --profile'))
+ expect(add).toContain('add \'dshmarket@^1.31.1\'')
+ })
+
it('installs plugins into the profile the options name', async () => {
const session = fakeSession((command) => {
if (command.includes('printf'))
diff --git a/packages/dsh-tauri-ssh/src/host/service/sync.ts b/packages/dsh-tauri-ssh/src/host/service/sync.ts
index 92163124..428754e3 100644
--- a/packages/dsh-tauri-ssh/src/host/service/sync.ts
+++ b/packages/dsh-tauri-ssh/src/host/service/sync.ts
@@ -16,7 +16,7 @@ import type { Buffer } from 'node:buffer'
import type { MachineId, SyncApplyResult, SyncItemResult, SyncPluginItem, SyncPluginRef, SyncPreview, SyncSkillItem, SyncSkillRef, SyncSkillRoot } from '../types/index'
import type { SshSession } from './transport'
import { DEFAULT_REMOTE_PROFILE } from '../storage/index'
-import { dshEntryProbeCommand, firstLineOf, layoutNodeBinary } from './bootstrap'
+import { dshEntryProbeCommand, firstLineOf, layoutBinDir, layoutNodeBinary } from './bootstrap'
import { shQuote } from './transport'
/**
@@ -30,6 +30,14 @@ export const REMOTE_PLUGIN_PROFILE = DEFAULT_REMOTE_PROFILE
/** How many output lines an item failure carries (the operator-facing tail). */
const FAILURE_TAIL_LINES = 5
+/**
+ * The desktop's own bundled plugins (`dsh-tauri*`). They ride the connect-time
+ * bundle sync automatically, so the manual sync list must not offer them:
+ * their `link:` specs are local paths that could never resolve remotely, and
+ * listing them as "not syncable" reads as a defect rather than a fact.
+ */
+const BUNDLED_PLUGIN_NAME = /^dsh-tauri(?:-|$)/u
+
/** Classify one dependency spec: can a remote `dsh plugin add` resolve it? */
export function classifySpec(spec: string): { syncable: boolean, reason?: string } {
const value = spec.trim()
@@ -47,15 +55,16 @@ export function classifySpec(spec: string): { syncable: boolean, reason?: string
/**
* Build the preview from the local sources: profile dependencies minus the
- * `@deepseek-ai/` core packages (the remote release ships those), and the
- * scanned skill roots. Both halves sorted by name for a stable panel order.
+ * `@deepseek-ai/` core packages (the remote release ships those) and minus
+ * {@link BUNDLED_PLUGIN_NAME} (they sync with the bundle automatically), plus
+ * the scanned skill roots. Both halves sorted by name for a stable panel order.
* @param dependencies - the profile package.json dependency map.
* @param skillRoots - per root, the SKILL.md directory names found locally.
* @returns the preview payload.
*/
export function buildPreview(dependencies: Record<string, string>, skillRoots: ReadonlyArray<{ root: SyncSkillRoot, names: readonly string[] }>): SyncPreview {
const plugins: SyncPluginItem[] = Object.entries(dependencies)
- .filter(([name]) => !name.startsWith('@deepseek-ai/'))
+ .filter(([name]) => !name.startsWith('@deepseek-ai/') && !BUNDLED_PLUGIN_NAME.test(name))
.map(([name, spec]) => {
const verdict = classifySpec(spec)
return {
@@ -76,16 +85,31 @@ export function buildPreview(dependencies: Record<string, string>, skillRoots: R
}
/**
- * The remote plugin-install command for one spec (dsh add is pnpm-backed).
- * The dsh entry is a Node script in the binary layout, so it always runs
- * under the layout's Node binary (never a bare `dsh` from the login PATH).
+ * The `dsh plugin add` argument for one profile dependency: a git spec is a
+ * complete locator on its own, while a version spec (`^1.0.0`, `latest`) only
+ * means something together with the package name — passing the bare range
+ * makes pnpm reject the install.
+ */
+export function installSpecOf(name: string, spec: string): string {
+ const value = spec.trim()
+ return /^(?:github:|git\+|git@)/u.test(value) ? value : `${name}@${value}`
+}
+
+/**
+ * The remote plugin-install command for one dependency (dsh add is
+ * pnpm-backed). The dsh entry is a Node script in the binary layout, so it
+ * always runs under the layout's Node binary (never a bare `dsh` from the
+ * login PATH).
* @param dshEntry - the absolute entry path the layout probe resolved.
- * @param spec - the dependency spec to install.
+ * @param target - the install argument, see {@link installSpecOf}.
* @param profileName - the remote profile to install into.
* @returns the shell command line.
*/
-export function pluginAddCommand(dshEntry: string, spec: string, profileName: string = REMOTE_PLUGIN_PROFILE): string {
- return `${layoutNodeBinary()} ${shQuote(dshEntry)} plugin --profile ${shQuote(profileName)} add ${shQuote(spec)}`
+export function pluginAddCommand(dshEntry: string, target: string, profileName: string = REMOTE_PLUGIN_PROFILE): string {
+ // `dsh plugin add` spawns a bare `pnpm`: the layout bin dir carries the
+ // shim the connect pipeline writes (see `ensurePnpmCommand`), so prepend it
+ // to PATH for this command only.
+ return `PATH="${layoutBinDir()}:$PATH" ${layoutNodeBinary()} ${shQuote(dshEntry)} plugin --profile ${shQuote(profileName)} add ${shQuote(target)}`
}
/** The remote skill-extract command; the tarball arrives on its stdin. */
@@ -204,7 +228,7 @@ export class SyncEngine {
})
continue
}
- const result = await session.exec(pluginAddCommand(dshEntry, plugin.spec, options.profileName), {
+ const result = await session.exec(pluginAddCommand(dshEntry, installSpecOf(plugin.name, plugin.spec), options.profileName), {
...this.deps.commandTimeoutMs === undefined ? {} : { timeoutMs: this.deps.commandTimeoutMs },
})
items.push(