The fork was pinned at upstream v0.18.0. That is the entire reason the window
ran TWO sidebars and TWO near-identical panel toggles: DSH 2.0.10 ships its own
right sidebar (@deepseek-ai/dsh-client-ui-sidebar-right), and upstream only
adopted it in v0.19.0-alpha.1 — which arrived after our fork point. v0.19.1 is
also the one upstream line whose support range actually matches our host
(engines.dsh >=0.1.5-rc.1, 14 DSH peers ^0.1.5-rc.1, host = 0.1.5-rc.2), so it
is the only tag the host's startup precheck accepts.
What upstream v0.18.0 → v0.19.1 brings
- src/client/native/{index,surface,tab-adapter}.tsx: every tab the plugin can
draw becomes an OFFICIAL native tab type + body, and an external plugin's
descriptor registered later gets its native type too. This is what retires
the fork's own right panel — and with it the duplicate toggle cluster
(`toggleCluster` is gone from v0.19.1).
- native tab-chip icons via the `sidebar.right.pane.tab.title` seat, coloured
built-in tab icons, file/folder glyphs from DSH's own `FileTypeIcon`.
- guide descriptions (DSH renders them while the guide lists <= 4 entries),
tab bodies that fill the panel, and the 0.1.5-rc.2 adaptation work we were
carrying by hand (peer/devDep pinning, primitives' transitive devDeps).
How the sync was done
Rebuilt the tree from the v0.19.1 tag rather than resolving 53 conflicted
files: our v0.18.0 delta was measured first and is only (a) one mechanical
rename `dsh-better-sidebar` -> `dsh-apes-sidebar` and (b) ten real edits. So:
tag tree + rename (scoped: code/config/scripts/tests/README, while the 46
historical docs/plans records and switch.sh's upstream package name stay
untouched) + re-applied deltas + our apes module.
Fork deltas re-applied on the new base
- src/client/apes/ (icons / locales / tabs): the three apes:* information-layer
tabs (agents / apps / profile), registered through the same BetterSidebarService
as the builtins — which is exactly why they now ride upstream's native adapter
into the official sidebar for free.
- identity: package.json (name/version 1.2.0/description/forkedFrom), dsh.plugin.json
(id/version), SIDEBAR_SERVICE_VERSION 1.2.0, README fork notice,
docs/external-plugin-guide.md.
- scripts/switch.sh + the pnpm switch* scripts (apes <-> upstream two-line switch).
- tests/apes-tabs.spec.ts (unescaped: it starts from the v0.19.1 base).
Dropped
- the Phase A native-registration spike (`apes/native-tabs.tsx` + its spec): it
re-derived by hand exactly what upstream's native layer already does — the
hand-written bridge is dead weight now, and v0.19.1's own e2e/jsdom lanes
cover the same seat contract far better.
- the unused apesProfileGuideDesc key and the two package.json.bak.* backups.
Verified on the new base: typecheck clean; build clean; 1351 passed / 9 skipped
(128 files), up from 1255 on the old base.
146 lines
5.9 KiB
TypeScript
146 lines
5.9 KiB
TypeScript
import { spawnSync } from 'node:child_process'
|
|
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { delimiter, join, resolve } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
|
|
const ROOT = resolve(fileURLToPath(new URL('..', import.meta.url)))
|
|
const INSTALLER = resolve(ROOT, 'scripts/install.ps1')
|
|
const INSTALLER_URL = 'https://raw.githubusercontent.com/omdsh-dev/DSH-better-sidebar/main/scripts/install.ps1'
|
|
const tempDirs: string[] = []
|
|
const hasPwsh = process.platform === 'win32'
|
|
&& spawnSync('pwsh', ['-NoLogo', '-NoProfile', '-Command', 'exit 0'], { stdio: 'ignore' }).status === 0
|
|
|
|
interface InstallerFixture {
|
|
home: string
|
|
path: string
|
|
workspace: string
|
|
}
|
|
|
|
function createFixture(pnpmVersion: string): InstallerFixture {
|
|
const root = mkdtempSync(join(tmpdir(), 'dshbs-install-'))
|
|
tempDirs.push(root)
|
|
const home = join(root, 'home')
|
|
const profile = join(home, 'profiles', 'web')
|
|
const bin = join(root, 'bin')
|
|
mkdirSync(profile, { recursive: true })
|
|
mkdirSync(bin)
|
|
const workspace = 'packages:\n - .\n'
|
|
writeFileSync(join(profile, 'pnpm-workspace.yaml'), workspace)
|
|
writeFileSync(join(bin, 'pnpm.cmd'), `@echo off\r\necho ${pnpmVersion}\r\n`)
|
|
return {
|
|
home,
|
|
workspace,
|
|
path: `${bin}${delimiter}${process.env.PATH ?? ''}`,
|
|
}
|
|
}
|
|
|
|
function runPowerShell(executable: string, args: string[], fixture: InstallerFixture) {
|
|
return spawnSync(executable, ['-NoLogo', '-NoProfile', ...args], {
|
|
encoding: 'utf8',
|
|
env: {
|
|
...process.env,
|
|
DSH_CMD: 'dsh',
|
|
DSH_HOME: fixture.home,
|
|
INSTALLER_PATH: INSTALLER,
|
|
PATH: fixture.path,
|
|
},
|
|
})
|
|
}
|
|
|
|
function assertInMemoryInvocation(executable: string): void {
|
|
const fixture = createFixture('10.34.5')
|
|
const command = [
|
|
'$bytes = [IO.File]::ReadAllBytes($env:INSTALLER_PATH)',
|
|
'$script = [Text.Encoding]::UTF8.GetString($bytes).TrimStart([char]0xFEFF)',
|
|
'& ([scriptblock]::Create($script)) -Version 0.11.0 -DryRun',
|
|
].join('; ')
|
|
const result = runPowerShell(executable, ['-Command', command], fixture)
|
|
const output = `${result.stdout}\n${result.stderr}`
|
|
|
|
expect(result.status, output).toBe(0)
|
|
expect(output).toContain('dsh-apes-sidebar@0.11.0')
|
|
expect(output).toContain('[dry-run]')
|
|
expect(output).not.toContain('False False')
|
|
}
|
|
|
|
afterEach(() => {
|
|
for (const dir of tempDirs.splice(0)) rmSync(dir, { recursive: true, force: true })
|
|
})
|
|
|
|
/**
|
|
* The Windows cases here spawn a real PowerShell (`powershell.exe` 5.1 or
|
|
* `pwsh`) per assertion, and a cold 5.1 start on a loaded 2-core CI runner
|
|
* measured 12.1 s (ci-windows run 34494370187) — more than twice vitest's
|
|
* 5000 ms default, which is why this file kept losing that case. The
|
|
* file-content cases below share the suite budget but finish in
|
|
* milliseconds either way.
|
|
*/
|
|
describe('PowerShell installer entry points', { timeout: 30_000 }, () => {
|
|
it('keeps the UTF-8 BOM required by Windows PowerShell 5.1 -File decoding', () => {
|
|
expect(readFileSync(INSTALLER).subarray(0, 3)).toEqual(Buffer.from([0xef, 0xbb, 0xbf]))
|
|
})
|
|
|
|
it('documents only BOM-safe in-memory invocation', () => {
|
|
for (const file of ['README.md', 'README_EN.md', 'scripts/install.ps1']) {
|
|
const source = readFileSync(resolve(ROOT, file), 'utf8')
|
|
expect(source, file).not.toMatch(new RegExp(`irm [^\\r\\n]*${INSTALLER_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[^\\r\\n]*\\|\\s*iex`, 'i'))
|
|
expect(source, file).not.toMatch(/\[scriptblock\]::Create\(\(irm\b/i)
|
|
// Where remote invocation IS documented, it must be BOM-safe: the
|
|
// READMEs switched to the prompt-based install flow and no longer
|
|
// document `irm` at all, so the TrimStart gate applies to the script
|
|
// (whose usage comment demonstrates the safe pattern).
|
|
const documentsInvocation = /\birm\b|\$script\s*=|\[scriptblock\]/.test(source)
|
|
if (documentsInvocation) {
|
|
expect(source.match(/\.TrimStart\(\[char\]0xFEFF\)/g)?.length, file).toBeGreaterThanOrEqual(2)
|
|
}
|
|
}
|
|
})
|
|
|
|
it('keeps the versioned installer usage example self-contained', () => {
|
|
const source = readFileSync(INSTALLER, 'utf8')
|
|
const versionedExample = source.slice(
|
|
source.indexOf('# # 指定版本 / 装完重启'),
|
|
source.indexOf('# # 本地保存后运行'),
|
|
)
|
|
|
|
expect(versionedExample).toContain(INSTALLER_URL)
|
|
expect(versionedExample).toContain('.TrimStart([char]0xFEFF)')
|
|
expect(versionedExample).toContain('-Version 0.10.2 -Restart')
|
|
})
|
|
|
|
it.runIf(process.platform === 'win32')('binds parameters when loaded into memory by Windows PowerShell 5.1', () => {
|
|
assertInMemoryInvocation('powershell.exe')
|
|
})
|
|
|
|
it.runIf(hasPwsh)('binds parameters when loaded into memory by pwsh, when available', () => {
|
|
assertInMemoryInvocation('pwsh')
|
|
})
|
|
|
|
it.runIf(process.platform === 'win32')('retains the Windows PowerShell 5.1 -File entry point', () => {
|
|
const fixture = createFixture('10.34.5')
|
|
const result = runPowerShell('powershell.exe', [
|
|
'-ExecutionPolicy', 'Bypass', '-File', INSTALLER, '-Version', '0.11.0', '-DryRun',
|
|
], fixture)
|
|
const output = `${result.stdout}\n${result.stderr}`
|
|
|
|
expect(result.status, output).toBe(0)
|
|
expect(output).toContain('dsh-apes-sidebar@0.11.0')
|
|
expect(output).toContain('[dry-run]')
|
|
})
|
|
|
|
it.runIf(process.platform === 'win32')('rejects pnpm 8 before changing the profile', () => {
|
|
const fixture = createFixture('8.15.9')
|
|
const workspacePath = join(fixture.home, 'profiles', 'web', 'pnpm-workspace.yaml')
|
|
const result = runPowerShell('powershell.exe', [
|
|
'-ExecutionPolicy', 'Bypass', '-File', INSTALLER, '-Version', '0.11.0', '-DryRun',
|
|
], fixture)
|
|
const output = `${result.stdout}\n${result.stderr}`
|
|
|
|
expect(result.status, output).toBe(1)
|
|
expect(output).toContain('pnpm >= 10')
|
|
expect(readFileSync(workspacePath, 'utf8')).toBe(fixture.workspace)
|
|
})
|
|
})
|