fix: emit DeepSeek Harness bundle manifest

This commit is contained in:
mesalogo
2026-08-15 18:06:03 +08:00
parent f27dd37f42
commit 9cd565fcc4
2 changed files with 76 additions and 1 deletions
+58 -1
View File
@@ -1,6 +1,62 @@
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path' import { resolve } from 'node:path'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite' import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import type { Plugin } from 'vite'
type ProjectPackage = {
dependencies?: Record<string, string>
}
const projectPackage = JSON.parse(
readFileSync(resolve('package.json'), 'utf8')
) as ProjectPackage
function requireDependencyVersion(
dependencies: Record<string, string> | undefined,
name: string
): string {
const version = dependencies?.[name]
if (!version) {
throw new Error(`Missing ${name} dependency version`)
}
return version
}
const deepSeekHarnessLlmVersion = requireDependencyVersion(
projectPackage.dependencies,
'@deepseek-ai/dsh-llm'
)
export function serializeDeepSeekHarnessBundleManifest(
version: string
): string {
return `${JSON.stringify(
{
name: '@deepseek-ai/dsh-llm',
version,
private: true,
type: 'module'
},
null,
2
)}\n`
}
function deepSeekHarnessBundleManifestPlugin(): Plugin {
return {
name: 'deepseek-harness-bundle-manifest',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'package.json',
source: serializeDeepSeekHarnessBundleManifest(
deepSeekHarnessLlmVersion
)
})
}
}
}
export default defineConfig({ export default defineConfig({
main: { main: {
@@ -34,7 +90,8 @@ export default defineConfig({
'yaml', 'yaml',
'zod' 'zod'
] ]
}) }),
deepSeekHarnessBundleManifestPlugin()
], ],
build: { build: {
rollupOptions: { rollupOptions: {
+18
View File
@@ -0,0 +1,18 @@
// @vitest-environment node
import { describe, expect, it } from 'vitest'
import { serializeDeepSeekHarnessBundleManifest } from '../electron.vite.config'
describe('Electron Vite configuration', () => {
it('serializes the DeepSeek Harness bundle manifest', () => {
const source = serializeDeepSeekHarnessBundleManifest('1.2.3')
expect(JSON.parse(source)).toEqual({
name: '@deepseek-ai/dsh-llm',
version: '1.2.3',
private: true,
type: 'module'
})
expect(source.endsWith('\n')).toBe(true)
})
})